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/ie/broker/api_dispatcher.h" | 9 #include "ceee/ie/broker/api_dispatcher.h" |
10 #include "ceee/ie/common/api_registration.h" | 10 #include "ceee/ie/common/api_registration.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 | 61 |
62 virtual void Run() { | 62 virtual void Run() { |
63 ProductionApiDispatcher::get()->HandleApiRequest(message_, NULL); | 63 ProductionApiDispatcher::get()->HandleApiRequest(message_, NULL); |
64 } | 64 } |
65 private: | 65 private: |
66 CComBSTR message_; | 66 CComBSTR message_; |
67 }; | 67 }; |
68 | 68 |
69 class FireEventTask : public Task { | 69 class FireEventTask : public Task { |
70 public: | 70 public: |
71 FireEventTask(BSTR event_name, BSTR event_args) | 71 FireEventTask(const char* event_name, const char* event_args) |
72 : event_name_(event_name), event_args_(event_args) {} | 72 : event_name_(event_name), event_args_(event_args) {} |
73 | 73 |
74 virtual void Run() { | 74 virtual void Run() { |
75 ProductionApiDispatcher::get()->FireEvent(event_name_, event_args_); | 75 ProductionApiDispatcher::get()->FireEvent(event_name_.c_str(), |
76 event_args_.c_str()); | |
76 } | 77 } |
77 private: | 78 private: |
78 CComBSTR event_name_; | 79 std::string event_name_; |
79 CComBSTR event_args_; | 80 std::string event_args_; |
80 }; | 81 }; |
81 | 82 |
82 | 83 |
83 ChromePostman* ChromePostman::single_instance_ = NULL; | 84 ChromePostman* ChromePostman::single_instance_ = NULL; |
84 ChromePostman::ChromePostman() { | 85 ChromePostman::ChromePostman() { |
85 DCHECK(single_instance_ == NULL); | 86 DCHECK(single_instance_ == NULL); |
86 single_instance_ = this; | 87 single_instance_ = this; |
87 frame_reset_count_ = 0; | 88 frame_reset_count_ = 0; |
88 } | 89 } |
89 | 90 |
(...skipping 21 matching lines...) Expand all Loading... | |
111 if (message_loop) { | 112 if (message_loop) { |
112 message_loop->PostTask( | 113 message_loop->PostTask( |
113 FROM_HERE, new ChromeFrameMessageTask(&chrome_postman_thread_, | 114 FROM_HERE, new ChromeFrameMessageTask(&chrome_postman_thread_, |
114 message, target)); | 115 message, target)); |
115 } else { | 116 } else { |
116 LOG(ERROR) << "Trying to post a message before the postman thread is" | 117 LOG(ERROR) << "Trying to post a message before the postman thread is" |
117 "completely initialized and ready."; | 118 "completely initialized and ready."; |
118 } | 119 } |
119 } | 120 } |
120 | 121 |
121 void ChromePostman::FireEvent(BSTR event_name, BSTR event_args) { | 122 void ChromePostman::FireEvent(const char* event_name, const char* event_args) { |
122 MessageLoop* message_loop = api_worker_thread_.message_loop(); | 123 MessageLoop* message_loop = api_worker_thread_.message_loop(); |
123 if (message_loop) { | 124 if (message_loop) { |
124 message_loop->PostTask(FROM_HERE, | 125 message_loop->PostTask(FROM_HERE, |
Sigurður Ásgeirsson
2010/11/19 18:29:30
while you're in here, can I ask you to remove the
Vitaly Buka corp
2010/11/19 20:30:38
Done.
| |
125 new FireEventTask(event_name, event_args)); | 126 new FireEventTask(event_name, event_args)); |
126 } else { | 127 } else { |
127 LOG(ERROR) << "Trying to post a message before the API worker thread is" | 128 LOG(ERROR) << "Trying to post a message before the API worker thread is" |
128 "completely initialized and ready."; | 129 "completely initialized and ready."; |
129 } | 130 } |
130 } | 131 } |
131 | 132 |
132 HRESULT ChromePostman::OnCfReadyStateChanged(LONG state) { | 133 HRESULT ChromePostman::OnCfReadyStateChanged(LONG state) { |
133 if (state == READYSTATE_COMPLETE) { | 134 if (state == READYSTATE_COMPLETE) { |
134 // If the page is fully loaded, we reset the count to 0 to ensure we restart | 135 // If the page is fully loaded, we reset the count to 0 to ensure we restart |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
291 void ChromePostman::ApiInvocationWorkerThread::Init() { | 292 void ChromePostman::ApiInvocationWorkerThread::Init() { |
292 ::CoInitializeEx(0, COINIT_MULTITHREADED); | 293 ::CoInitializeEx(0, COINIT_MULTITHREADED); |
293 ProductionApiDispatcher::get()->SetApiInvocationThreadId( | 294 ProductionApiDispatcher::get()->SetApiInvocationThreadId( |
294 ::GetCurrentThreadId()); | 295 ::GetCurrentThreadId()); |
295 } | 296 } |
296 | 297 |
297 void ChromePostman::ApiInvocationWorkerThread::CleanUp() { | 298 void ChromePostman::ApiInvocationWorkerThread::CleanUp() { |
298 ::CoUninitialize(); | 299 ::CoUninitialize(); |
299 ProductionApiDispatcher::get()->SetApiInvocationThreadId(0); | 300 ProductionApiDispatcher::get()->SetApiInvocationThreadId(0); |
300 } | 301 } |
OLD | NEW |