| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ | 5 #ifndef REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ |
| 6 #define REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ | 6 #define REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ |
| 7 | 7 |
| 8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 | 11 |
| 12 namespace net { | 12 namespace net { |
| 13 class URLRequestContextGetter; | 13 class URLRequestContextGetter; |
| 14 } // namespace net | 14 } // namespace net |
| 15 | 15 |
| 16 namespace remoting { | 16 namespace remoting { |
| 17 | 17 |
| 18 class AutoThreadTaskRunner; | 18 class AutoThreadTaskRunner; |
| 19 | 19 |
| 20 // A class that manages threads and running context for the chromoting host | 20 // A class that manages threads and running context for the chromoting host |
| 21 // process. This class is virtual only for testing purposes (see below). | 21 // process. This class is virtual only for testing purposes (see below). |
| 22 class ChromotingHostContext { | 22 class ChromotingHostContext { |
| 23 public: | 23 public: |
| 24 // Create threads and URLRequestContextGetter for use by a host. | 24 // Create threads and URLRequestContextGetter for use by a host. |
| 25 // During shutdown the caller should tear-down the ChromotingHostContext and | 25 // During shutdown the caller should tear-down the ChromotingHostContext and |
| 26 // then continue to run until |ui_task_runner| is no longer referenced. | 26 // then continue to run until |ui_task_runner| is no longer referenced. |
| 27 // NULL is returned if any threads fail to start. | 27 // nullptr is returned if any threads fail to start. |
| 28 static scoped_ptr<ChromotingHostContext> Create( | 28 static scoped_ptr<ChromotingHostContext> Create( |
| 29 scoped_refptr<AutoThreadTaskRunner> ui_task_runner); | 29 scoped_refptr<AutoThreadTaskRunner> ui_task_runner); |
| 30 | 30 |
| 31 #if defined(OS_CHROMEOS) | 31 #if defined(OS_CHROMEOS) |
| 32 // Attaches task runners to the relevant browser threads for the chromoting | 32 // Attaches task runners to the relevant browser threads for the chromoting |
| 33 // host. Must be called on the UI thread of the browser process. | 33 // host. Must be called on the UI thread of the browser process. |
| 34 // remoting::UrlRequestContextGetter returns BasicURLRequestContext under | 34 // remoting::UrlRequestContextGetter returns BasicURLRequestContext under |
| 35 // the hood which spawns two new threads per instance. Since | 35 // the hood which spawns two new threads per instance. Since |
| 36 // ChromotingHostContext can be destroyed from any thread, as its owner | 36 // ChromotingHostContext can be destroyed from any thread, as its owner |
| 37 // (It2MeHost) is ref-counted, joining the created threads during shutdown | 37 // (It2MeHost) is ref-counted, joining the created threads during shutdown |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 111 |
| 112 // Serves URLRequestContexts that use the network and UI task runners. | 112 // Serves URLRequestContexts that use the network and UI task runners. |
| 113 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; | 113 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; |
| 114 | 114 |
| 115 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext); | 115 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext); |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 } // namespace remoting | 118 } // namespace remoting |
| 119 | 119 |
| 120 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ | 120 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ |
| OLD | NEW |