| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 WIN8_VIEWER_METRO_VIEWER_PROCESS_HOST_H_ | 5 #ifndef WIN8_VIEWER_METRO_VIEWER_PROCESS_HOST_H_ |
| 6 #define WIN8_VIEWER_METRO_VIEWER_PROCESS_HOST_H_ | 6 #define WIN8_VIEWER_METRO_VIEWER_PROCESS_HOST_H_ |
| 7 | 7 |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 11 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| 13 #include "base/threading/non_thread_safe.h" | 11 #include "base/threading/non_thread_safe.h" |
| 14 #include "ipc/ipc_channel_proxy.h" | 12 #include "ipc/ipc_channel_proxy.h" |
| 15 #include "ipc/ipc_listener.h" | 13 #include "ipc/ipc_listener.h" |
| 16 #include "ipc/ipc_sender.h" | 14 #include "ipc/ipc_sender.h" |
| 17 #include "ui/gfx/native_widget_types.h" | 15 #include "ui/gfx/native_widget_types.h" |
| 18 | 16 |
| 19 namespace base { | 17 namespace base { |
| 20 class SingleThreadTaskRunner; | 18 class SingleThreadTaskRunner; |
| 21 class WaitableEvent; | 19 class WaitableEvent; |
| 22 } | 20 } |
| 23 | 21 |
| 24 namespace IPC { | 22 namespace IPC { |
| 25 class Message; | 23 class Message; |
| 26 } | 24 } |
| 27 | 25 |
| 28 namespace win8 { | 26 namespace win8 { |
| 29 | 27 |
| 30 // Abstract base class for various Metro viewer process host implementations. | 28 // Abstract base class for various Metro viewer process host implementations. |
| 31 class MetroViewerProcessHost : public IPC::Listener, | 29 class MetroViewerProcessHost : public IPC::Listener, |
| 32 public IPC::Sender, | 30 public IPC::Sender, |
| 33 public base::NonThreadSafe { | 31 public base::NonThreadSafe { |
| 34 public: | 32 public: |
| 35 // Initializes a viewer process host over |ipc_channel_name|. The given task | 33 // Initializes a viewer process host to connect to the Metro viewer process |
| 36 // runner correspond to a thread on which IPC::Channel is created and used | 34 // over IPC. The given task runner correspond to a thread on which |
| 37 // (e.g. IO thread). Instantly connects to the viewer process if one is | 35 // IPC::Channel is created and used (e.g. IO thread). Instantly connects to |
| 38 // already connected to |ipc_channel_name|; a viewer can otherwise be | 36 // the viewer process if one is already connected to |ipc_channel_name|; a |
| 39 // launched synchronously via LaunchViewerAndWaitForConnection(). | 37 // viewer can otherwise be launched synchronously via |
| 40 MetroViewerProcessHost(const std::string& ipc_channel_name, | 38 // LaunchViewerAndWaitForConnection(). |
| 41 base::SingleThreadTaskRunner* ipc_task_runner); | 39 explicit MetroViewerProcessHost( |
| 40 base::SingleThreadTaskRunner* ipc_task_runner); |
| 42 virtual ~MetroViewerProcessHost(); | 41 virtual ~MetroViewerProcessHost(); |
| 43 | 42 |
| 44 // Returns the process id of the viewer process if one is connected to this | 43 // Returns the process id of the viewer process if one is connected to this |
| 45 // host, returns base::kNullProcessId otherwise. | 44 // host, returns base::kNullProcessId otherwise. |
| 46 base::ProcessId GetViewerProcessId(); | 45 base::ProcessId GetViewerProcessId(); |
| 47 | 46 |
| 48 // Launches the viewer process associated with the given |app_user_model_id| | 47 // Launches the viewer process associated with the given |app_user_model_id| |
| 49 // and blocks until that viewer process connects or until a timeout is | 48 // and blocks until that viewer process connects or until a timeout is |
| 50 // reached. Returns true if the viewer process connects before the timeout is | 49 // reached. Returns true if the viewer process connects before the timeout is |
| 51 // reached. NOTE: this assumes that the app referred to by |app_user_model_id| | 50 // reached. NOTE: this assumes that the app referred to by |app_user_model_id| |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 93 |
| 95 scoped_ptr<IPC::ChannelProxy> channel_; | 94 scoped_ptr<IPC::ChannelProxy> channel_; |
| 96 scoped_ptr<base::WaitableEvent> channel_connected_event_; | 95 scoped_ptr<base::WaitableEvent> channel_connected_event_; |
| 97 | 96 |
| 98 DISALLOW_COPY_AND_ASSIGN(MetroViewerProcessHost); | 97 DISALLOW_COPY_AND_ASSIGN(MetroViewerProcessHost); |
| 99 }; | 98 }; |
| 100 | 99 |
| 101 } // namespace win8 | 100 } // namespace win8 |
| 102 | 101 |
| 103 #endif // WIN8_VIEWER_METRO_VIEWER_PROCESS_HOST_H_ | 102 #endif // WIN8_VIEWER_METRO_VIEWER_PROCESS_HOST_H_ |
| OLD | NEW |