OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 MOJO_SERVICES_NETWORK_NETWORK_SERVICE_DELEGATE_H_ | 5 #ifndef MOJO_SERVICES_NETWORK_NETWORK_SERVICE_DELEGATE_H_ |
6 #define MOJO_SERVICES_NETWORK_NETWORK_SERVICE_DELEGATE_H_ | 6 #define MOJO_SERVICES_NETWORK_NETWORK_SERVICE_DELEGATE_H_ |
7 | 7 |
8 #include "base/observer_list.h" | 8 #include "base/observer_list.h" |
9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
10 #include "components/filesystem/public/interfaces/file_system.mojom.h" | 10 #include "components/filesystem/public/interfaces/file_system.mojom.h" |
11 #include "mojo/application/public/cpp/application_delegate.h" | 11 #include "mojo/application/public/cpp/application_delegate.h" |
12 #include "mojo/application/public/cpp/application_impl.h" | 12 #include "mojo/application/public/cpp/application_impl.h" |
13 #include "mojo/application/public/cpp/interface_factory.h" | 13 #include "mojo/application/public/cpp/interface_factory.h" |
14 #include "mojo/services/network/network_context.h" | 14 #include "mojo/services/network/network_context.h" |
| 15 #include "mojo/services/network/public/interfaces/cookie_store.mojom.h" |
15 #include "mojo/services/network/public/interfaces/network_service.mojom.h" | 16 #include "mojo/services/network/public/interfaces/network_service.mojom.h" |
16 #include "mojo/services/network/public/interfaces/url_loader_factory.mojom.h" | 17 #include "mojo/services/network/public/interfaces/url_loader_factory.mojom.h" |
17 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_ptr.h" | 18 #include "mojo/services/network/public/interfaces/web_socket_factory.mojom.h" |
18 | 19 |
19 namespace sql { | 20 namespace sql { |
20 class ScopedMojoFilesystemVFS; | 21 class ScopedMojoFilesystemVFS; |
21 } | 22 } |
22 | 23 |
23 namespace mojo { | 24 namespace mojo { |
24 class NetworkServiceDelegateObserver; | 25 class NetworkServiceDelegateObserver; |
25 | 26 |
26 class NetworkServiceDelegate | 27 class NetworkServiceDelegate : public ApplicationDelegate, |
27 : public mojo::ApplicationDelegate, | 28 public InterfaceFactory<NetworkService>, |
28 public mojo::InterfaceFactory<mojo::NetworkService>, | 29 public InterfaceFactory<CookieStore>, |
29 public mojo::InterfaceFactory<mojo::URLLoaderFactory>, | 30 public InterfaceFactory<WebSocketFactory>, |
30 public filesystem::FileSystemClient { | 31 public InterfaceFactory<URLLoaderFactory>, |
| 32 public filesystem::FileSystemClient { |
31 public: | 33 public: |
32 NetworkServiceDelegate(); | 34 NetworkServiceDelegate(); |
33 ~NetworkServiceDelegate() override; | 35 ~NetworkServiceDelegate() override; |
34 | 36 |
35 void AddObserver(NetworkServiceDelegateObserver* observer); | 37 void AddObserver(NetworkServiceDelegateObserver* observer); |
36 void RemoveObserver(NetworkServiceDelegateObserver* observer); | 38 void RemoveObserver(NetworkServiceDelegateObserver* observer); |
37 | 39 |
38 private: | 40 private: |
39 // Notifies all of our observers of a Shuts down our IO thread. Safe to call | 41 // Notifies all of our observers of a Shuts down our IO thread. Safe to call |
40 // multiple times. | 42 // multiple times. |
41 void EnsureIOThreadShutdown(); | 43 void EnsureIOThreadShutdown(); |
42 | 44 |
43 // mojo::ApplicationDelegate implementation. | 45 // ApplicationDelegate implementation. |
44 void Initialize(mojo::ApplicationImpl* app) override; | 46 void Initialize(ApplicationImpl* app) override; |
45 bool ConfigureIncomingConnection( | 47 bool ConfigureIncomingConnection(ApplicationConnection* connection) override; |
46 mojo::ApplicationConnection* connection) override; | |
47 bool OnShellConnectionError() override; | 48 bool OnShellConnectionError() override; |
48 void Quit() override; | 49 void Quit() override; |
49 | 50 |
50 // mojo::InterfaceFactory<mojo::NetworkService> implementation. | 51 // InterfaceFactory<NetworkService> implementation. |
51 void Create(mojo::ApplicationConnection* connection, | 52 void Create(ApplicationConnection* connection, |
52 mojo::InterfaceRequest<mojo::NetworkService> request) override; | 53 InterfaceRequest<NetworkService> request) override; |
53 | 54 |
54 // mojo::InterfaceFactory<mojo::URLLoaderFactory> implementation. | 55 // InterfaceFactory<CookieStore> implementation. |
55 void Create(mojo::ApplicationConnection* connection, | 56 void Create(ApplicationConnection* connection, |
56 mojo::InterfaceRequest<mojo::URLLoaderFactory> request) override; | 57 InterfaceRequest<CookieStore> request) override; |
| 58 |
| 59 // InterfaceFactory<WebSocketFactory> implementation. |
| 60 void Create(ApplicationConnection* connection, |
| 61 InterfaceRequest<WebSocketFactory> request) override; |
| 62 |
| 63 // InterfaceFactory<URLLoaderFactory> implementation. |
| 64 void Create(ApplicationConnection* connection, |
| 65 InterfaceRequest<URLLoaderFactory> request) override; |
57 | 66 |
58 // Overridden from FileSystemClient: | 67 // Overridden from FileSystemClient: |
59 void OnFileSystemShutdown() override; | 68 void OnFileSystemShutdown() override; |
60 | 69 |
61 private: | 70 private: |
62 mojo::ApplicationImpl* app_; | 71 ApplicationImpl* app_; |
63 | 72 |
64 // Observers that want notifications that our worker thread is going away. | 73 // Observers that want notifications that our worker thread is going away. |
65 base::ObserverList<NetworkServiceDelegateObserver> observers_; | 74 base::ObserverList<NetworkServiceDelegateObserver> observers_; |
66 | 75 |
67 mojo::Binding<filesystem::FileSystemClient> binding_; | 76 Binding<filesystem::FileSystemClient> binding_; |
68 | 77 |
69 // A worker thread that blocks for file IO. | 78 // A worker thread that blocks for file IO. |
70 scoped_ptr<base::Thread> io_worker_thread_; | 79 scoped_ptr<base::Thread> io_worker_thread_; |
71 | 80 |
72 // Our connection to the filesystem service, which stores our cookies and | 81 // Our connection to the filesystem service, which stores our cookies and |
73 // other data. | 82 // other data. |
74 filesystem::FileSystemPtr files_; | 83 filesystem::FileSystemPtr files_; |
75 | 84 |
76 scoped_ptr<mojo::NetworkContext> context_; | 85 scoped_ptr<NetworkContext> context_; |
77 }; | 86 }; |
78 | 87 |
79 } // namespace mojo | 88 } // namespace mojo |
80 | 89 |
81 #endif // MOJO_SERVICES_NETWORK_NETWORK_SERVICE_DELEGATE_H_ | 90 #endif // MOJO_SERVICES_NETWORK_NETWORK_SERVICE_DELEGATE_H_ |
OLD | NEW |