|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: COomClientRequestQueue.cpp. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef COOMCLIENTREQUESTQUEUE_H |
|
20 #define COOMCLIENTREQUESTQUEUE_H |
|
21 |
|
22 #include <e32std.h> |
|
23 #include <e32base.h> |
|
24 #include <e32property.h> |
|
25 |
|
26 #include "oommemorymonitor.h" |
|
27 |
|
28 class COomClientRequestQueue; |
|
29 class CMemoryMonitor; |
|
30 class CSubscribeHelper; |
|
31 |
|
32 class TClientRequest |
|
33 { |
|
34 public: |
|
35 TClientRequest(TActionTriggerType aClientRequestType, TInt aBytesRequested); |
|
36 TClientRequest(TActionTriggerType aClientRequestType, const RMessage2& aRequestFreeRam); |
|
37 public: |
|
38 TActionTriggerType iClientRequestType; |
|
39 TInt iBytesRequested; |
|
40 RMessage2 iRequestFreeRamMessage; |
|
41 TSglQueLink iLink; |
|
42 }; |
|
43 |
|
44 /* |
|
45 * If two client requests are queued, the COomClientRequestTimer is used to wait after the first request |
|
46 * has been completed, to allow the first client time to allocate the memory it requested. |
|
47 * |
|
48 * @lib oommonitor.lib |
|
49 * @since S60 v5.0 |
|
50 */ |
|
51 NONSHARABLE_CLASS(COomClientRequestTimer) : public CTimer |
|
52 { |
|
53 public: |
|
54 static COomClientRequestTimer* NewL(COomClientRequestQueue& aQueue); |
|
55 private: |
|
56 COomClientRequestTimer(COomClientRequestQueue& aQueue); |
|
57 void RunL(); |
|
58 |
|
59 private: //data |
|
60 COomClientRequestQueue& iClientRequestQueue; |
|
61 }; |
|
62 |
|
63 /** |
|
64 * Queues client requests so that the actual RAM level of the device is in a state where it can be more |
|
65 * accurately determined whether more actions need to be run |
|
66 * |
|
67 * @lib oommonitor.lib |
|
68 * @since S60 v5.0 |
|
69 */ |
|
70 NONSHARABLE_CLASS(COomClientRequestQueue) : public CBase |
|
71 { |
|
72 public: |
|
73 |
|
74 // Constructors and destructor |
|
75 |
|
76 /** |
|
77 * Destructor. |
|
78 */ |
|
79 ~COomClientRequestQueue(); |
|
80 |
|
81 /** |
|
82 * Two-phased constructor. |
|
83 */ |
|
84 static COomClientRequestQueue* NewL(CMemoryMonitor& aMonitor); |
|
85 |
|
86 CMemoryMonitor& Monitor(); |
|
87 |
|
88 void RequestFreeMemoryL(const RMessage2& aMessage); |
|
89 void RequestOptionalRamL(const RMessage2& aMessage); |
|
90 void ActionsCompleted(TInt aBytesFree, TBool aMemoryGood); |
|
91 void RequestTimerCallbackL(); |
|
92 |
|
93 private: |
|
94 |
|
95 /** |
|
96 * Constructor for performing 1st stage construction |
|
97 */ |
|
98 COomClientRequestQueue(CMemoryMonitor& aMonitor); |
|
99 |
|
100 /** |
|
101 * EPOC default constructor for performing 2nd stage construction |
|
102 */ |
|
103 void ConstructL(); |
|
104 |
|
105 static TInt WatchdogStatusStatusChanged(TAny* aPtr); |
|
106 void HandleWatchdogStatusCallBack(); |
|
107 void AddClientRequestL(TClientRequest& request); |
|
108 void StartClientRequestL(); |
|
109 |
|
110 // parameters for P&S watcher. |
|
111 |
|
112 /** |
|
113 * The handle to the P&S property that can be used to initiate OOM Monitor actions |
|
114 */ |
|
115 RProperty iWatchdogStatusProperty; |
|
116 |
|
117 /** |
|
118 * The active object which monitors the P&S property that can be used to initiate OOM Monitor actions |
|
119 * Own. |
|
120 */ |
|
121 CSubscribeHelper* iWatchdogStatusSubscriber; |
|
122 |
|
123 TSglQue<TClientRequest> iQueue; |
|
124 |
|
125 TBool iClientRequestActive; |
|
126 |
|
127 CMemoryMonitor& iMonitor; |
|
128 |
|
129 COomClientRequestTimer* iClientRequestTimer; |
|
130 |
|
131 TTime iLastClientCompletedTime; |
|
132 }; |
|
133 |
|
134 #endif // COOMCLIENTREQUESTQUEUE_H |