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" |
9 #include "ceee/ie/broker/api_dispatcher.h" | 10 #include "ceee/ie/broker/api_dispatcher.h" |
10 #include "ceee/ie/common/api_registration.h" | 11 #include "ceee/ie/common/api_registration.h" |
11 #include "ceee/ie/common/ceee_module_util.h" | 12 #include "ceee/ie/common/ceee_module_util.h" |
12 #include "chrome/browser/automation/extension_automation_constants.h" | 13 #include "chrome/browser/automation/extension_automation_constants.h" |
13 #include "chrome/common/url_constants.h" | 14 #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 |
124 void ChromePostman::FireEvent(const char* event_name, const char* event_args) { | 134 void ChromePostman::FireEvent(const char* event_name, const char* event_args) { |
125 MessageLoop* message_loop = api_worker_thread_.message_loop(); | 135 MessageLoop* message_loop = api_worker_thread_.message_loop(); |
126 if (message_loop) { | 136 if (message_loop) { |
127 // TODO(siggi@chromium.org): Remove the task subclass and change this to | 137 // TODO(siggi@chromium.org): Remove the task subclass and change this to |
128 // use NewRunnableMethod. | 138 // use NewRunnableMethod. |
129 message_loop->PostTask(FROM_HERE, | 139 message_loop->PostTask(FROM_HERE, |
130 new FireEventTask(event_name, event_args)); | 140 new FireEventTask(event_name, event_args)); |
131 } else { | 141 } else { |
132 LOG(ERROR) << "Trying to post a message before the API worker thread is" | 142 LOG(ERROR) << "Trying to post a message before the API worker thread is" |
133 "completely initialized and ready."; | 143 "completely initialized and ready."; |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 void ChromePostman::ApiInvocationWorkerThread::Init() { | 306 void ChromePostman::ApiInvocationWorkerThread::Init() { |
297 ::CoInitializeEx(0, COINIT_MULTITHREADED); | 307 ::CoInitializeEx(0, COINIT_MULTITHREADED); |
298 ProductionApiDispatcher::get()->SetApiInvocationThreadId( | 308 ProductionApiDispatcher::get()->SetApiInvocationThreadId( |
299 ::GetCurrentThreadId()); | 309 ::GetCurrentThreadId()); |
300 } | 310 } |
301 | 311 |
302 void ChromePostman::ApiInvocationWorkerThread::CleanUp() { | 312 void ChromePostman::ApiInvocationWorkerThread::CleanUp() { |
303 ::CoUninitialize(); | 313 ::CoUninitialize(); |
304 ProductionApiDispatcher::get()->SetApiInvocationThreadId(0); | 314 ProductionApiDispatcher::get()->SetApiInvocationThreadId(0); |
305 } | 315 } |
OLD | NEW |