|
1 /* |
|
2 * ============================================================================ |
|
3 * Name : NestedAO.h |
|
4 * Part of : Base Plugin |
|
5 * |
|
6 * Description: |
|
7 * Class used to implement nested active object used to handle deletion |
|
8 * of large number of messages by breaking them into smaller chunks |
|
9 * Version: |
|
10 * |
|
11 * Copyright (C) 2010 Nokia Corporation. |
|
12 * This material, including documentation and any related |
|
13 * computer programs, is protected by copyright controlled by |
|
14 * Nokia Corporation. All rights are reserved. Copying, |
|
15 * including reproducing, storing, adapting or translating, any |
|
16 * or all of this material requires the prior written consent of |
|
17 * Nokia Corporation. This material also contains confidential |
|
18 * information which may not be disclosed to others without the |
|
19 * prior written consent of Nokia Corporation. |
|
20 * ============================================================================ |
|
21 */ |
|
22 |
|
23 #ifndef __NESTED_AO_H__ |
|
24 #define __NESTED_AO_H__ |
|
25 |
|
26 // Include Files |
|
27 |
|
28 |
|
29 #include <e32base.h> |
|
30 |
|
31 |
|
32 class MDeletionHandler |
|
33 { |
|
34 public: |
|
35 enum TState |
|
36 { |
|
37 EInProgress, |
|
38 EFree |
|
39 }; |
|
40 //Deletes messages from aStartIndex KSizeOfChunk at a time |
|
41 virtual TBool DeleteMessagesInChunksL( TInt aStartIndex ) = 0; |
|
42 }; |
|
43 //Time interval between issuing 2 requests to delete messages |
|
44 const TInt KWaitIntervalInMicroSecs=500; |
|
45 //Maximum number of messages deleted in one go |
|
46 const TInt KSizeOfChunk=10; |
|
47 |
|
48 NONSHARABLE_CLASS ( CNestedAO ) : public CTimer |
|
49 { |
|
50 public: |
|
51 |
|
52 static CNestedAO* NewL( MDeletionHandler& aDeletionHandler ); |
|
53 virtual ~CNestedAO(); |
|
54 // -------------------------------------------------------------------------- |
|
55 // CNestedAO::DeleteMessagesAsync |
|
56 // Used to delete messages asynchronously |
|
57 // Deleting a small number of messages at a time |
|
58 // ------------ |
|
59 void DeleteMessagesAsync(); |
|
60 // -------------------------------------------------------------------------- |
|
61 // CNestedAO::Rc |
|
62 // Used to return the iStatus return value |
|
63 // ------------ |
|
64 TInt Rc() { return iRc; } |
|
65 |
|
66 private: |
|
67 CNestedAO( MDeletionHandler& aDeletionHandler ); |
|
68 void ConstructL(); |
|
69 |
|
70 // inherited from CActive |
|
71 virtual void RunL(); |
|
72 virtual void DoCancel(); |
|
73 // -------------------------------------------------------------------------- |
|
74 // CNestedAO::Stop |
|
75 // Stops the scheduler from running |
|
76 // Called after all messages are processed |
|
77 // or in error condition |
|
78 // ------------ |
|
79 void Stop(); |
|
80 |
|
81 private: |
|
82 CActiveSchedulerWait* iNestedWait; |
|
83 MDeletionHandler& iDeletionHandler; |
|
84 TInt iDeletionIndex; |
|
85 TInt iRc; |
|
86 }; |
|
87 |
|
88 |
|
89 #endif //__NESTED_AO_H__ |