OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef UI_VIEWER_VIEWER_PROCESS_H_ | |
6 #define UI_VIEWER_VIEWER_PROCESS_H_ | |
7 | |
8 #include "base/memory/ref_counted.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/message_loop_proxy.h" | |
11 #include "base/synchronization/waitable_event.h" | |
12 #include "base/threading/thread.h" | |
13 | |
14 class CommandLine; | |
15 class ViewerHostWin; | |
16 class ViewerIPCServer; | |
17 | |
18 // The ViewerProcess does not inherit from ChildProcess because this | |
19 // process can live independently of the browser process. | |
20 class ViewerProcess { | |
21 public: | |
22 ViewerProcess(); | |
23 virtual ~ViewerProcess(); | |
24 | |
25 // Initialize the ViewerProcess with the message loop that it should run on. | |
26 // ViewerProcess takes ownership of |state|. | |
27 bool Initialize(MessageLoop* message_loop, const CommandLine& command_line); | |
28 | |
29 bool Teardown(); | |
30 | |
31 // Returns the message loop that we perform I/O coordination on (network | |
32 // requests, communication with renderers, etc.). | |
33 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy() { | |
34 return io_thread_->message_loop_proxy(); | |
35 } | |
36 | |
37 // A global event object that is signalled when the main thread's message | |
38 // loop exits. This gives background threads a way to observe the main | |
39 // thread shutting down. | |
40 base::WaitableEvent* shutdown_event() { | |
41 return &shutdown_event_; | |
42 } | |
43 | |
44 // Called by the IPC server when a client disconnects. A return value of | |
45 // true indicates that the IPC server should continue listening for new | |
46 // connections. | |
47 bool HandleClientDisconnect(); | |
48 | |
49 void Terminate(); | |
50 | |
51 private: | |
52 scoped_ptr<base::Thread> io_thread_; | |
53 scoped_ptr<ViewerIPCServer> ipc_server_; | |
54 | |
55 // An event that will be signalled when we shutdown. | |
56 base::WaitableEvent shutdown_event_; | |
57 | |
58 // Window that we draw into. | |
59 scoped_ptr<ViewerHostWin> viewer_host_win_; | |
60 | |
61 // Pointer to the main message loop that host this object. | |
62 MessageLoop* main_message_loop_; | |
63 | |
64 DISALLOW_COPY_AND_ASSIGN(ViewerProcess); | |
65 }; | |
66 | |
67 extern ViewerProcess* g_viewer_process; | |
68 | |
69 #endif // UI_VIEWER_VIEWER_PROCESS_H_ | |
OLD | NEW |