os/kernelhwsrv/kerneltest/f32test/shostmassstorage/testclient/usbtestmsclient/inc/drivepublisher.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // Drive publishing classes for USB Mass Storage.
    15 // RDriveMediaErrorPublisher,
    16 // RDriveStateChangedPublisher,
    17 // CUsbTransferPublisher,
    18 // CUsbReadTransferPublisher,
    19 // CUsbReadTransferPublisher.
    20 // 
    21 //
    22 
    23 
    24 
    25 /**
    26  @file
    27  @internalTechnology
    28 */
    29 
    30 #ifndef DRIVEPUBLISHER_H
    31 #define DRIVEPUBLISHER_H
    32 
    33 
    34 // forward declaration
    35 class CMassStorageDrive;
    36 
    37 typedef TFixedArray<CMassStorageDrive*, KUsbMsMaxDrives>& TRefMsDriveList;
    38 
    39 typedef TFixedArray<TInt64, KUsbMsMaxDrives> TBytesTransferedList;
    40 
    41 //----------------------------------------------------------------------------
    42 /**
    43 @internalTechnology
    44 
    45 Publishes the EUsbMsDriveState_MediaError property.
    46 */
    47 class RDriveMediaErrorPublisher
    48 {
    49 public:
    50 	RDriveMediaErrorPublisher();
    51 	~RDriveMediaErrorPublisher();
    52 
    53 	void PublishErrorL(TBool aError);
    54 
    55 private:
    56 	/**
    57 	Publish and subscribe property for EUsbMsDriveState_MediaError property
    58 	*/
    59 	RProperty iMediaErrorProperty;
    60 };
    61 
    62 //----------------------------------------------------------------------------
    63 /**
    64 @internalTechnology
    65 
    66 Publishes the EUsbMsDriveState_DriveStatus property value for a drive state change.
    67 The published drive state is mapped from the drive's mount state and drive state.
    68 */
    69 
    70 class RDriveStateChangedPublisher
    71 {
    72 public:
    73 	RDriveStateChangedPublisher(const TMsDriveList& aDrives, const TLunToDriveMap& aDriveMap);
    74 	~RDriveStateChangedPublisher();
    75 	void DriveStateChanged();
    76 
    77 private:
    78 	/**
    79 	Reference to the array of drives. The index into the array is a LUN.
    80 	*/
    81 	const TMsDriveList& iDrives;
    82 
    83 	/**
    84 	Reference to the drive map to convert LUN to Drive Number.
    85 	*/
    86 	const TLunToDriveMap& iDriveMap;
    87 };
    88 
    89 
    90 //----------------------------------------------------------------------------
    91 // measure bytes transfered at the USB interface
    92 //----------------------------------------------------------------------------
    93 
    94 /**
    95 @internalTechnology
    96 
    97 Base class for Read and Write publihsers.
    98 */
    99 class CUsbTransferPublisher : public CBase
   100 {
   101 protected:
   102 	~CUsbTransferPublisher();
   103 
   104 	CUsbTransferPublisher(TUsbMsDriveState_Subkey iSubKey,
   105 						  const TBytesTransferedList& aBytesTransferred);
   106 	void ConstructL();
   107 
   108 public:
   109 	void StartTimer();
   110 	void StopTimer();
   111 	void DoPublishDataTransferredEvent();
   112 
   113 private:
   114 	TUint GetBytesTransferred(TLun aLun) const;
   115 
   116 	// No of calls to wait without an data transfer from iTimer
   117 	// before stopping the publish timer.
   118 	enum {ETimerCancelDelay = 5};
   119 
   120 	static TInt PublishDataTransferredEvent(TAny* obj);
   121 	TBool PublishDataTransferred();
   122 
   123 protected:
   124 	TUsbMsDriveState_Subkey iSubKey;
   125 	/**
   126 	Reference to the array of drives. The index into the array is a LUN.
   127 	*/
   128 	const TBytesTransferedList& iArray;
   129 
   130 	/**
   131 	Publish and subscribe properties for tracking data transfer volume
   132 	*/
   133 	RProperty iProperty;
   134 
   135 private:
   136 	/**
   137 	An active object which triggers periodic updates to subscribers.
   138 	*/
   139 	CPeriodic* iTimer;
   140 
   141 	/**
   142 	Set to ETrue when iTimer is running, EFalse otherwise
   143 	*/
   144 	TBool iTimerRunning;
   145 
   146 	/**
   147 	Adds delay between data not being transferred and iTimer being cancelled
   148 	*/
   149 	TInt iTimerCancelCnt;
   150 };
   151 
   152 //----------------------------------------------------------------------------
   153 /**
   154 @internalTechnology
   155 
   156 Publishes EUsbMsDriveState_KBytesWritten property values for tracking data transfer write volume.
   157 */
   158 class CUsbWriteTransferPublisher: public CUsbTransferPublisher
   159 {
   160 public:
   161 	static CUsbWriteTransferPublisher* NewL(const TBytesTransferedList& aBytesTransferred);
   162 
   163 private:
   164 	CUsbWriteTransferPublisher(const TBytesTransferedList& aBytesTransferred);
   165 };
   166 
   167 //----------------------------------------------------------------------------
   168 /**
   169 @internalTechnology
   170 
   171 Publishes EUsbMsDriveState_KBytesRead property value for tracking data transfer read volume.
   172 */
   173 class CUsbReadTransferPublisher: public CUsbTransferPublisher
   174 {
   175 public:
   176 	static CUsbReadTransferPublisher* NewL(const TBytesTransferedList& aBytesTransferred);
   177 
   178 private:
   179 	CUsbReadTransferPublisher(const TBytesTransferedList& aBytesTransferred);
   180 };
   181 
   182 #endif //__DRIVEPUBLISHER_H__