OLD | NEW |
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 // ChromePostman implementation. | 5 // ChromePostman implementation. |
6 #include "ceee/ie/broker/chrome_postman.h" | 6 #include "ceee/ie/broker/chrome_postman.h" |
7 | 7 |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "ceee/common/com_utils.h" | |
10 #include "ceee/ie/broker/api_dispatcher.h" | 9 #include "ceee/ie/broker/api_dispatcher.h" |
11 #include "ceee/ie/common/api_registration.h" | 10 #include "ceee/ie/common/api_registration.h" |
12 #include "ceee/ie/common/ceee_module_util.h" | 11 #include "ceee/ie/common/ceee_module_util.h" |
13 #include "chrome/browser/automation/extension_automation_constants.h" | 12 #include "chrome/browser/automation/extension_automation_constants.h" |
14 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
| 14 #include "ceee/common/com_utils.h" |
15 | 15 |
16 namespace ext = extension_automation_constants; | 16 namespace ext = extension_automation_constants; |
17 | 17 |
18 namespace { | 18 namespace { |
19 // The maximum number of times we should try to start Frame. | 19 // The maximum number of times we should try to start Frame. |
20 const unsigned int kMaxFrameResetCount = 5; | 20 const unsigned int kMaxFrameResetCount = 5; |
21 } | 21 } |
22 | 22 |
23 class ChromeFrameMessageTask : public Task { | 23 class ChromeFrameMessageTask : public Task { |
24 public: | 24 public: |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 // use NewRunnableMethod. | 114 // use NewRunnableMethod. |
115 message_loop->PostTask( | 115 message_loop->PostTask( |
116 FROM_HERE, new ChromeFrameMessageTask(&chrome_postman_thread_, | 116 FROM_HERE, new ChromeFrameMessageTask(&chrome_postman_thread_, |
117 message, target)); | 117 message, target)); |
118 } else { | 118 } else { |
119 LOG(ERROR) << "Trying to post a message before the postman thread is" | 119 LOG(ERROR) << "Trying to post a message before the postman thread is" |
120 "completely initialized and ready."; | 120 "completely initialized and ready."; |
121 } | 121 } |
122 } | 122 } |
123 | 123 |
124 void ChromePostman::QueueApiInvocationThreadTask(Task* task) { | |
125 MessageLoop* message_loop = api_worker_thread_.message_loop(); | |
126 if (message_loop) { | |
127 message_loop->PostTask(FROM_HERE, task); | |
128 } else { | |
129 LOG(ERROR) << "Trying to queue a task before the API worker thread is" | |
130 "completely initialized and ready."; | |
131 } | |
132 } | |
133 | |
134 void ChromePostman::FireEvent(const char* event_name, const char* event_args) { | 124 void ChromePostman::FireEvent(const char* event_name, const char* event_args) { |
135 MessageLoop* message_loop = api_worker_thread_.message_loop(); | 125 MessageLoop* message_loop = api_worker_thread_.message_loop(); |
136 if (message_loop) { | 126 if (message_loop) { |
137 // TODO(siggi@chromium.org): Remove the task subclass and change this to | 127 // TODO(siggi@chromium.org): Remove the task subclass and change this to |
138 // use NewRunnableMethod. | 128 // use NewRunnableMethod. |
139 message_loop->PostTask(FROM_HERE, | 129 message_loop->PostTask(FROM_HERE, |
140 new FireEventTask(event_name, event_args)); | 130 new FireEventTask(event_name, event_args)); |
141 } else { | 131 } else { |
142 LOG(ERROR) << "Trying to post a message before the API worker thread is" | 132 LOG(ERROR) << "Trying to post a message before the API worker thread is" |
143 "completely initialized and ready."; | 133 "completely initialized and ready."; |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 void ChromePostman::ApiInvocationWorkerThread::Init() { | 309 void ChromePostman::ApiInvocationWorkerThread::Init() { |
320 ::CoInitializeEx(0, COINIT_MULTITHREADED); | 310 ::CoInitializeEx(0, COINIT_MULTITHREADED); |
321 ProductionApiDispatcher::get()->SetApiInvocationThreadId( | 311 ProductionApiDispatcher::get()->SetApiInvocationThreadId( |
322 ::GetCurrentThreadId()); | 312 ::GetCurrentThreadId()); |
323 } | 313 } |
324 | 314 |
325 void ChromePostman::ApiInvocationWorkerThread::CleanUp() { | 315 void ChromePostman::ApiInvocationWorkerThread::CleanUp() { |
326 ::CoUninitialize(); | 316 ::CoUninitialize(); |
327 ProductionApiDispatcher::get()->SetApiInvocationThreadId(0); | 317 ProductionApiDispatcher::get()->SetApiInvocationThreadId(0); |
328 } | 318 } |
OLD | NEW |