|
1 // Copyright (c) 2006-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 "Symbian Foundation License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "lbsmemlogger.h" |
|
17 #include "claunchedprocess.h" |
|
18 #include "csecureprocessasbase.h" |
|
19 |
|
20 |
|
21 /** Create instance of trap handler and cleanup stack |
|
22 called by the launched process! |
|
23 |
|
24 @return Symbian error code |
|
25 @internalTechnology |
|
26 @released |
|
27 */ |
|
28 TInt CLaunchedProcess::CompleteProcessLaunch() |
|
29 { |
|
30 __UHEAP_MARK; |
|
31 CTrapCleanup* cleanup=CTrapCleanup::New(); |
|
32 TInt r=KErrNoMemory; |
|
33 if (cleanup) |
|
34 { |
|
35 TRAP(r,DoCompleteProcessLaunchL()); |
|
36 delete cleanup; |
|
37 } |
|
38 __UHEAP_MARKEND; |
|
39 return r; |
|
40 |
|
41 } |
|
42 |
|
43 |
|
44 /** Create the server process, create, install and run the active scheduler |
|
45 wait for scheduler to be stopped to return process |
|
46 |
|
47 @return Symbian error code |
|
48 @internalTechnology |
|
49 @released |
|
50 */ |
|
51 TInt CLaunchedProcess::DoCompleteProcessLaunchL() |
|
52 { |
|
53 TInt r = KErrNone; |
|
54 // create and install the active scheduler we need |
|
55 CSecureProcessASBase* s=new(ELeave) CSecureProcessASBase(); |
|
56 CleanupStack::PushL(s); |
|
57 CActiveScheduler::Install(s); |
|
58 |
|
59 // Create the memory logger object for monitoring memory |
|
60 LBSMEMLOG_BEGIN(); |
|
61 |
|
62 CBase* baseObj = s->CreateRootObjectL(); |
|
63 |
|
64 CleanupStack::PushL(baseObj); |
|
65 |
|
66 r = s->EntryPointL(baseObj); |
|
67 |
|
68 RProcess().Rendezvous(KErrNone); |
|
69 |
|
70 // Ready to run |
|
71 CActiveScheduler::Start(); |
|
72 |
|
73 // |
|
74 // Cleanup the client |
|
75 CleanupStack::PopAndDestroy(1); |
|
76 |
|
77 // Cleanup the mem logger |
|
78 LBSMEMLOG_END(); |
|
79 |
|
80 // |
|
81 // do any _FINAL _ operations. If anything.. default does nothing |
|
82 s->Final(); |
|
83 // Cleanup the scheduler |
|
84 CleanupStack::PopAndDestroy(s); |
|
85 return r; |
|
86 } |
|
87 |
|
88 |
|
89 /** Create instance of trap cleanup stack and the process by specified parameters |
|
90 |
|
91 @param aParams A reference to TProcessStartParams object |
|
92 @return Symbian error code |
|
93 @see TProcessStartParams |
|
94 @internalTechnology |
|
95 @released |
|
96 */ |
|
97 TInt CLaunchedProcess::CompleteProcessLaunch(TProcessStartParams& aParams) |
|
98 { |
|
99 __UHEAP_MARK; |
|
100 CTrapCleanup* cleanup=CTrapCleanup::New(); |
|
101 TInt r=KErrNoMemory; |
|
102 if (cleanup) |
|
103 { |
|
104 TRAP(r,DoCompleteProcessLaunchL(aParams)); |
|
105 delete cleanup; |
|
106 } |
|
107 __UHEAP_MARKEND; |
|
108 return r; |
|
109 |
|
110 } |
|
111 |
|
112 /** Create the server process by specified parameters, create, install and run the active scheduler |
|
113 wait for scheduler to be stopped to return process |
|
114 |
|
115 @param aParams A reference to TProcessStartParams object |
|
116 @return Symbian error code |
|
117 @see TProcessStartParams |
|
118 @internalTechnology |
|
119 @released |
|
120 */ |
|
121 TInt CLaunchedProcess::DoCompleteProcessLaunchL(TProcessStartParams& aParams) |
|
122 { |
|
123 // first check that we are about to create the right type of server |
|
124 if(aParams.GetType() != KProcessStartParamsTypeUid) |
|
125 { |
|
126 // this is not a process type that we understand. Has the caller |
|
127 // pass TServerStartParams by mistake? |
|
128 User::Leave(KErrArgument); // this aborts the server startup |
|
129 } |
|
130 |
|
131 // rename our main thread |
|
132 User::LeaveIfError(User::RenameThread(aParams.GetProcessName())); |
|
133 |
|
134 TInt r = KErrNone; |
|
135 // create and install the active scheduler we need |
|
136 CSecureProcessASBase* s=new(ELeave) CSecureProcessASBase(); |
|
137 CleanupStack::PushL(s); |
|
138 CActiveScheduler::Install(s); |
|
139 |
|
140 // Create the memory logger object for monitoring memory |
|
141 LBSMEMLOG_BEGIN(); |
|
142 |
|
143 CBase* baseObj = s->CreateRootObjectL(); |
|
144 |
|
145 CleanupStack::PushL(baseObj); |
|
146 |
|
147 r = s->EntryPointL(baseObj); |
|
148 |
|
149 // is the process that started us interested in known that we are alive and well |
|
150 if(aParams.GetRendezvousRequired()) |
|
151 { |
|
152 // tell any starting process that we have started successfully and are |
|
153 // now ready to receieve mesages or process events |
|
154 RProcess::Rendezvous(KErrNone); |
|
155 } |
|
156 // Ready to run |
|
157 CActiveScheduler::Start(); |
|
158 // |
|
159 // Cleanup the client |
|
160 CleanupStack::PopAndDestroy(1); |
|
161 |
|
162 // Cleanup the mem logger |
|
163 LBSMEMLOG_END(); |
|
164 |
|
165 // |
|
166 // do any _FINAL _ operations. If anything.. default does nothing |
|
167 s->Final(); |
|
168 // Cleanup the scheduler |
|
169 CleanupStack::PopAndDestroy(s); |
|
170 return r; |
|
171 } |
|
172 |