Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: ceee/ie/broker/executors_manager.h

Issue 5581008: Add a new GetInstance() method for singleton classes, take 2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // @file 5 // @file
6 // ExecutorsManager implementation, an object to keep track of the 6 // ExecutorsManager implementation, an object to keep track of the
7 // CeeeExecutor objects that were instantiated in destination threads. 7 // CeeeExecutor objects that were instantiated in destination threads.
8 8
9 #ifndef CEEE_IE_BROKER_EXECUTORS_MANAGER_H_ 9 #ifndef CEEE_IE_BROKER_EXECUTORS_MANAGER_H_
10 #define CEEE_IE_BROKER_EXECUTORS_MANAGER_H_ 10 #define CEEE_IE_BROKER_EXECUTORS_MANAGER_H_
(...skipping 16 matching lines...) Expand all
27 // the instance of the Broker object does. 27 // the instance of the Broker object does.
28 // 28 //
29 // See the @ref ExecutorsManagerDoc page for more details. 29 // See the @ref ExecutorsManagerDoc page for more details.
30 30
31 // Manages a map of destination threads to CeeeExecutor interfaces. 31 // Manages a map of destination threads to CeeeExecutor interfaces.
32 class ExecutorsManager { 32 class ExecutorsManager {
33 public: 33 public:
34 // Identifiers for destination threads where to run executors. 34 // Identifiers for destination threads where to run executors.
35 typedef DWORD ThreadId; 35 typedef DWORD ThreadId;
36 36
37 // Returns the singleton instance.
38 static ExecutorsManager* GetInstance();
39
37 // To avoid lint errors, even though we are only virtual for unittests. 40 // To avoid lint errors, even though we are only virtual for unittests.
38 virtual ~ExecutorsManager() {} 41 virtual ~ExecutorsManager() {}
39 42
40 // Temporary until we have a better structure to recognize known windows. 43 // Temporary until we have a better structure to recognize known windows.
41 // TODO(mad@chromium.org): Find a better structure. 44 // TODO(mad@chromium.org): Find a better structure.
42 static bool IsKnownWindow(HWND window); 45 static bool IsKnownWindow(HWND window);
43 virtual bool IsKnownWindowImpl(HWND window); 46 virtual bool IsKnownWindowImpl(HWND window);
44 static HWND FindTabChild(HWND window); 47 static HWND FindTabChild(HWND window);
45 virtual HWND FindTabChildImpl(HWND window); 48 virtual HWND FindTabChildImpl(HWND window);
46 49
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // Register the relation between a tool band tab ID and an HWND. 121 // Register the relation between a tool band tab ID and an HWND.
119 virtual void SetTabToolBandIdForHandle(int tool_band_id, HWND tab_handle); 122 virtual void SetTabToolBandIdForHandle(int tool_band_id, HWND tab_handle);
120 123
121 // Unregister the HWND and its corresponding tab ID and tool band tab ID. 124 // Unregister the HWND and its corresponding tab ID and tool band tab ID.
122 virtual void DeleteTabHandle(HWND handle); 125 virtual void DeleteTabHandle(HWND handle);
123 126
124 // Cleans up the maps from all handles that would be associated to the given 127 // Cleans up the maps from all handles that would be associated to the given
125 // thread id. 128 // thread id.
126 virtual void CleanupMapsForThread(DWORD thread_id); 129 virtual void CleanupMapsForThread(DWORD thread_id);
127 130
131 protected:
128 // Traits for Singleton<ExecutorsManager> so that we can pass an argument 132 // Traits for Singleton<ExecutorsManager> so that we can pass an argument
129 // to the constructor. 133 // to the constructor.
130 struct SingletonTraits : public DefaultSingletonTraits<ExecutorsManager> { 134 struct SingletonTraits : public DefaultSingletonTraits<ExecutorsManager> {
131 static ExecutorsManager* New() { 135 static ExecutorsManager* New() {
132 if (test_instance_) 136 if (test_instance_)
133 return test_instance_; 137 return test_instance_;
134 else 138 else
135 return new ExecutorsManager(false); // By default, we want a thread. 139 return new ExecutorsManager(false); // By default, we want a thread.
136 } 140 }
137 }; 141 };
138 142
139 protected:
140 // The data we pass to start our worker thread. 143 // The data we pass to start our worker thread.
141 // THERE IS A COPY OF THIS CLASS IN THE UNITTEST WHICH YOU NEED TO UPDATE IF 144 // THERE IS A COPY OF THIS CLASS IN THE UNITTEST WHICH YOU NEED TO UPDATE IF
142 // you change this one... 145 // you change this one...
143 struct ThreadStartData { 146 struct ThreadStartData {
144 ExecutorsManager* me; 147 ExecutorsManager* me;
145 CHandle thread_started_gate; 148 CHandle thread_started_gate;
146 }; 149 };
147 150
148 // A structures holding on the info about an executor and thread it runs in. 151 // A structures holding on the info about an executor and thread it runs in.
149 struct ExecutorInfo { 152 struct ExecutorInfo {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 return windows_events_funnel_; 260 return windows_events_funnel_;
258 } 261 }
259 262
260 // Test seam too. 263 // Test seam too.
261 static ExecutorsManager* test_instance_; 264 static ExecutorsManager* test_instance_;
262 265
263 DISALLOW_COPY_AND_ASSIGN(ExecutorsManager); 266 DISALLOW_COPY_AND_ASSIGN(ExecutorsManager);
264 }; 267 };
265 268
266 #endif // CEEE_IE_BROKER_EXECUTORS_MANAGER_H_ 269 #endif // CEEE_IE_BROKER_EXECUTORS_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698