30 #include "panics.h" |
30 #include "panics.h" |
31 #include "inifile.h" |
31 #include "inifile.h" |
32 #include "pointer.h" |
32 #include "pointer.h" |
33 #include "WSGRAPHICDRAWERFACTORY.H" |
33 #include "WSGRAPHICDRAWERFACTORY.H" |
34 #include "redrawmsgwindow.h" |
34 #include "redrawmsgwindow.h" |
35 #include <Graphics/WSGRAPHICDRAWERINTERFACE.H> |
35 #include <graphics/WSGRAPHICDRAWERINTERFACE.H> |
36 #include "WsMemMgr.h" |
36 #include "WsMemMgr.h" |
37 #include "backedupwindow.h" |
37 #include "backedupwindow.h" |
38 #include "wsfont.h" |
38 #include "wsfont.h" |
39 #include "registeredsurfacemap.h" |
39 #include "registeredsurfacemap.h" |
40 #include <EGL/egl.h> |
40 #include <EGL/egl.h> |
44 #endif |
44 #endif |
45 |
45 |
46 #include "registeredsurfacemap.h" |
46 #include "registeredsurfacemap.h" |
47 #include "windowelementset.h" |
47 #include "windowelementset.h" |
48 #include "wspluginmanager.h" |
48 #include "wspluginmanager.h" |
|
49 #include "renderorientationtracker.h" |
49 |
50 |
50 // IDs of p&s properties that optionally contain callbacks that may be used |
51 // IDs of p&s properties that optionally contain callbacks that may be used |
51 // to release singletons owned by libraries at shutdown in order to make |
52 // to release singletons owned by libraries at shutdown in order to make |
52 // the memory leak tests work. |
53 // the memory leak tests work. |
53 // By convention, the ID is the same as the UID3 of the libary. |
54 // By convention, the ID is the same as the UID3 of the libary. |
207 const CWsClient* CWsTop::iTriggerHeapCheckOnClientExit=NULL; |
208 const CWsClient* CWsTop::iTriggerHeapCheckOnClientExit=NULL; |
208 TWsCheckHeapOnDisconnectMode CWsTop::iHeapCheckMode=EWsCheckHeapOnDisconnectModeNone; |
209 TWsCheckHeapOnDisconnectMode CWsTop::iHeapCheckMode=EWsCheckHeapOnDisconnectModeNone; |
209 TInt CWsTop::iCheckHeapResult=KErrNotReady; |
210 TInt CWsTop::iCheckHeapResult=KErrNotReady; |
210 TBool CWsTop::iDoHeapCheckAndRestart=EFalse; |
211 TBool CWsTop::iDoHeapCheckAndRestart=EFalse; |
211 #define RFbsSession_SendCommand_ShutDownMessage 1 // A FBS message that is not published yet and probably never will be. |
212 #define RFbsSession_SendCommand_ShutDownMessage 1 // A FBS message that is not published yet and probably never will be. |
|
213 CWsRenderOrienationTracker* CWsTop::iRenderOrientationTracker=NULL; |
212 |
214 |
213 static void DefineSingletonKey(const TUid& aSingletonKey) |
215 static void DefineSingletonKey(const TUid& aSingletonKey) |
214 /** |
216 /** |
215 * Defines a new property for a singleton key. WServ must only process |
217 * Defines a new property for a singleton key. WServ must only process |
216 * singleton keys that it created to prevent a malicious process with the |
218 * singleton keys that it created to prevent a malicious process with the |
895 void CWsTop::SetCheckHeapOnDisconnectMode(TWsCheckHeapOnDisconnectMode aCheckHeapOnDisconnectMode) |
901 void CWsTop::SetCheckHeapOnDisconnectMode(TWsCheckHeapOnDisconnectMode aCheckHeapOnDisconnectMode) |
896 { |
902 { |
897 iHeapCheckMode=aCheckHeapOnDisconnectMode; |
903 iHeapCheckMode=aCheckHeapOnDisconnectMode; |
898 } |
904 } |
899 |
905 |
900 static void ReportAllCurrentLevelLeaks() |
|
901 { |
|
902 class RHeapWalk: public RHeap |
|
903 { |
|
904 public: |
|
905 static void WalkCheckCell(TAny* aPtr, TCellType aType, TAny* aCell, TInt aLen) |
|
906 { |
|
907 RHeapWalk* heap=(RHeapWalk*)aPtr; |
|
908 (void)aCell; |
|
909 switch(aType) |
|
910 { |
|
911 case EGoodAllocatedCell: |
|
912 if ( ((SDebugCell*)aCell)->nestingLevel == heap->iNestingLevel ) |
|
913 { |
|
914 RDebug::Printf("Leaked heap cell: level %i, serial %i @ %08x : len=%d", |
|
915 heap->iNestingLevel, ((SDebugCell*)aCell)->allocCount, aCell, aLen); |
|
916 } |
|
917 break; |
|
918 } |
|
919 } |
|
920 }; |
|
921 |
|
922 User::Heap().DebugFunction(RHeap::EWalk, (TAny*)RHeapWalk::WalkCheckCell, &User::Heap()); |
|
923 } |
|
924 |
|
925 TBool CWsTop::NeedsHeapCheckAndRestart(TInt aStartHeapCount) |
906 TBool CWsTop::NeedsHeapCheckAndRestart(TInt aStartHeapCount) |
926 { |
907 { |
927 if (!iDoHeapCheckAndRestart) |
908 if (!iDoHeapCheckAndRestart) |
928 return(EFalse); |
909 return(EFalse); |
929 iDoHeapCheckAndRestart=EFalse; |
910 iDoHeapCheckAndRestart=EFalse; |
930 iCheckHeapResult=User::Heap().Count()-aStartHeapCount; |
911 iCheckHeapResult=User::Heap().Count()-aStartHeapCount; |
931 if(iCheckHeapResult > 0) |
912 if(iCheckHeapResult > 0) |
932 { |
913 { |
933 const TUint32 orphanedCell = User::Heap().__DbgMarkEnd(aStartHeapCount); |
914 const TUint32 orphanedCell = User::Heap().__DbgMarkEnd(aStartHeapCount); |
934 RDebug::Printf("Memory leak detected in wserv. First orphaned cell: 0x%8x", orphanedCell); |
915 RDebug::Printf("Memory leak detected in wserv. First orphaned cell: 0x%8x", orphanedCell); |
935 ReportAllCurrentLevelLeaks(); |
|
936 } |
916 } |
937 return(ETrue); |
917 return(ETrue); |
938 } |
918 } |
939 |
919 |
940 TInt CWsTop::FetchCheckHeapResult() |
920 TInt CWsTop::FetchCheckHeapResult() |
981 return ETrue; |
961 return ETrue; |
982 } |
962 } |
983 } |
963 } |
984 return EFalse; |
964 return EFalse; |
985 } |
965 } |
|
966 |
|
967 /** |
|
968 Checks to see if the render orientation has changed, and publishes any new orientaion |
|
969 via publish and subscribe |
|
970 |
|
971 @see KRenderOrientationCategory |
|
972 @see KRenderOrientationKey |
|
973 */ |
|
974 void CWsTop::CheckRenderOrientation() |
|
975 { |
|
976 iRenderOrientationTracker->CheckRenderOrientation(); |
|
977 } |
986 |
978 |
987 typedef TInt (*ShellEntryPoint)(TAny *); |
979 typedef TInt (*ShellEntryPoint)(TAny *); |
988 |
980 |
989 #if defined(__WINS__) |
981 #if defined(__WINS__) |
990 LOCAL_D const TUint KHeapSize=0x10000; |
982 LOCAL_D const TUint KHeapSize=0x10000; |