| 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/common/com_utils.h" |
| 10 #include "ceee/ie/broker/api_dispatcher.h" | 10 #include "ceee/ie/broker/api_dispatcher.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 private: | 53 private: |
| 54 ChromePostman::ChromePostmanThread* thread_object_; | 54 ChromePostman::ChromePostmanThread* thread_object_; |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 | 57 |
| 58 class ApiExecutionTask : public Task { | 58 class ApiExecutionTask : public Task { |
| 59 public: | 59 public: |
| 60 explicit ApiExecutionTask(BSTR message) : message_(message) {} | 60 explicit ApiExecutionTask(BSTR message) : message_(message) {} |
| 61 | 61 |
| 62 virtual void Run() { | 62 virtual void Run() { |
| 63 ProductionApiDispatcher::get()->HandleApiRequest(message_, NULL); | 63 ProductionApiDispatcher::GetInstance()->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(const char* event_name, const char* 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_.c_str(), | 75 ProductionApiDispatcher::GetInstance()->FireEvent(event_name_.c_str(), |
| 76 event_args_.c_str()); | 76 event_args_.c_str()); |
| 77 } | 77 } |
| 78 private: | 78 private: |
| 79 std::string event_name_; | 79 std::string event_name_; |
| 80 std::string event_args_; | 80 std::string event_args_; |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 | 83 |
| 84 ChromePostman* ChromePostman::single_instance_ = NULL; | 84 ChromePostman* ChromePostman::single_instance_ = NULL; |
| 85 ChromePostman::ChromePostman() { | 85 ChromePostman::ChromePostman() { |
| 86 DCHECK(single_instance_ == NULL); | 86 DCHECK(single_instance_ == NULL); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 DCHECK(thread_id() == ::GetCurrentThreadId()); | 311 DCHECK(thread_id() == ::GetCurrentThreadId()); |
| 312 chrome_frame_host_.CopyTo(host); | 312 chrome_frame_host_.CopyTo(host); |
| 313 } | 313 } |
| 314 | 314 |
| 315 ChromePostman::ApiInvocationWorkerThread::ApiInvocationWorkerThread() | 315 ChromePostman::ApiInvocationWorkerThread::ApiInvocationWorkerThread() |
| 316 : base::Thread("ApiInvocationWorker") { | 316 : base::Thread("ApiInvocationWorker") { |
| 317 } | 317 } |
| 318 | 318 |
| 319 void ChromePostman::ApiInvocationWorkerThread::Init() { | 319 void ChromePostman::ApiInvocationWorkerThread::Init() { |
| 320 ::CoInitializeEx(0, COINIT_MULTITHREADED); | 320 ::CoInitializeEx(0, COINIT_MULTITHREADED); |
| 321 ProductionApiDispatcher::get()->SetApiInvocationThreadId( | 321 ProductionApiDispatcher::GetInstance()->SetApiInvocationThreadId( |
| 322 ::GetCurrentThreadId()); | 322 ::GetCurrentThreadId()); |
| 323 } | 323 } |
| 324 | 324 |
| 325 void ChromePostman::ApiInvocationWorkerThread::CleanUp() { | 325 void ChromePostman::ApiInvocationWorkerThread::CleanUp() { |
| 326 ::CoUninitialize(); | 326 ::CoUninitialize(); |
| 327 ProductionApiDispatcher::get()->SetApiInvocationThreadId(0); | 327 ProductionApiDispatcher::GetInstance()->SetApiInvocationThreadId(0); |
| 328 } | 328 } |
| OLD | NEW |