| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_FRAME_CUSTOM_SYNC_CALL_CONTEXT_H_ | 5 #ifndef CHROME_FRAME_CUSTOM_SYNC_CALL_CONTEXT_H_ |
| 6 #define CHROME_FRAME_CUSTOM_SYNC_CALL_CONTEXT_H_ | 6 #define CHROME_FRAME_CUSTOM_SYNC_CALL_CONTEXT_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
| 11 #include "chrome_frame/sync_msg_reply_dispatcher.h" | 11 #include "chrome_frame/sync_msg_reply_dispatcher.h" |
| 12 #include "chrome_frame/chrome_frame_automation.h" | 12 #include "chrome_frame/chrome_frame_automation.h" |
| 13 #include "ipc/ipc_sync_message.h" | 13 #include "ipc/ipc_sync_message.h" |
| 14 | 14 |
| 15 // TODO(ananta) | 15 // TODO(ananta) |
| 16 // Move the implementations of these classes to the source file. | 16 // Move the implementations of these classes to the source file. |
| 17 | 17 |
| 18 // Class that maintains context during the async load/install extension | |
| 19 // operation. When done, InstallExtensionComplete is posted back to the UI | |
| 20 // thread so that the users of ChromeFrameAutomationClient can be notified. | |
| 21 class InstallExtensionContext | |
| 22 : public SyncMessageReplyDispatcher::SyncMessageCallContext { | |
| 23 public: | |
| 24 typedef Tuple1<AutomationMsg_ExtensionResponseValues> output_type; | |
| 25 | |
| 26 InstallExtensionContext(ChromeFrameAutomationClient* client, | |
| 27 const FilePath& crx_path, void* user_data) : client_(client), | |
| 28 crx_path_(crx_path), user_data_(user_data) { | |
| 29 } | |
| 30 | |
| 31 ~InstallExtensionContext() { | |
| 32 } | |
| 33 | |
| 34 void Completed(AutomationMsg_ExtensionResponseValues res) { | |
| 35 client_->PostTask(FROM_HERE, NewRunnableMethod(client_.get(), | |
| 36 &ChromeFrameAutomationClient::InstallExtensionComplete, crx_path_, | |
| 37 user_data_, res)); | |
| 38 } | |
| 39 | |
| 40 private: | |
| 41 scoped_refptr<ChromeFrameAutomationClient> client_; | |
| 42 FilePath crx_path_; | |
| 43 void* user_data_; | |
| 44 }; | |
| 45 | |
| 46 // Class that maintains context during the async retrieval of fetching the | |
| 47 // list of enabled extensions. When done, GetEnabledExtensionsComplete is | |
| 48 // posted back to the UI thread so that the users of | |
| 49 // ChromeFrameAutomationClient can be notified. | |
| 50 class GetEnabledExtensionsContext | |
| 51 : public SyncMessageReplyDispatcher::SyncMessageCallContext { | |
| 52 public: | |
| 53 typedef Tuple1<std::vector<FilePath> > output_type; | |
| 54 | |
| 55 GetEnabledExtensionsContext( | |
| 56 ChromeFrameAutomationClient* client, void* user_data) : client_(client), | |
| 57 user_data_(user_data) { | |
| 58 extension_directories_ = new std::vector<FilePath>(); | |
| 59 } | |
| 60 | |
| 61 ~GetEnabledExtensionsContext() { | |
| 62 // ChromeFrameAutomationClient::GetEnabledExtensionsComplete takes | |
| 63 // ownership of extension_directories_. | |
| 64 } | |
| 65 | |
| 66 std::vector<FilePath>* extension_directories() { | |
| 67 return extension_directories_; | |
| 68 } | |
| 69 | |
| 70 void Completed( | |
| 71 std::vector<FilePath> result) { | |
| 72 (*extension_directories_) = result; | |
| 73 client_->PostTask(FROM_HERE, NewRunnableMethod(client_.get(), | |
| 74 &ChromeFrameAutomationClient::GetEnabledExtensionsComplete, | |
| 75 user_data_, extension_directories_)); | |
| 76 } | |
| 77 | |
| 78 private: | |
| 79 scoped_refptr<ChromeFrameAutomationClient> client_; | |
| 80 std::vector<FilePath>* extension_directories_; | |
| 81 void* user_data_; | |
| 82 }; | |
| 83 | |
| 84 // Class that maintains contextual information for the create and connect | 18 // Class that maintains contextual information for the create and connect |
| 85 // external tab operations. | 19 // external tab operations. |
| 86 class CreateExternalTabContext | 20 class CreateExternalTabContext |
| 87 : public SyncMessageReplyDispatcher::SyncMessageCallContext { | 21 : public SyncMessageReplyDispatcher::SyncMessageCallContext { |
| 88 public: | 22 public: |
| 89 typedef Tuple4<HWND, HWND, int, int> output_type; | 23 typedef Tuple4<HWND, HWND, int, int> output_type; |
| 90 explicit CreateExternalTabContext(ChromeFrameAutomationClient* client) | 24 explicit CreateExternalTabContext(ChromeFrameAutomationClient* client) |
| 91 : client_(client) { | 25 : client_(client) { |
| 92 } | 26 } |
| 93 | 27 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 // This object will be destroyed after this. Cannot access any members | 78 // This object will be destroyed after this. Cannot access any members |
| 145 // on returning from this function. | 79 // on returning from this function. |
| 146 } | 80 } |
| 147 | 81 |
| 148 private: | 82 private: |
| 149 base::WaitableEvent* unload_done_; | 83 base::WaitableEvent* unload_done_; |
| 150 bool* should_unload_; | 84 bool* should_unload_; |
| 151 }; | 85 }; |
| 152 | 86 |
| 153 #endif // CHROME_FRAME_CUSTOM_SYNC_CALL_CONTEXT_H_ | 87 #endif // CHROME_FRAME_CUSTOM_SYNC_CALL_CONTEXT_H_ |
| OLD | NEW |