| 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/macros.h" |
| 8 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
| 9 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| 10 #include "mojo/services/network/network_context.h" | 11 #include "mojo/services/network/network_context.h" |
| 11 #include "mojo/services/network/public/interfaces/cookie_store.mojom.h" | 12 #include "mojo/services/network/public/interfaces/cookie_store.mojom.h" |
| 12 #include "mojo/services/network/public/interfaces/network_service.mojom.h" | 13 #include "mojo/services/network/public/interfaces/network_service.mojom.h" |
| 13 #include "mojo/services/network/public/interfaces/url_loader_factory.mojom.h" | 14 #include "mojo/services/network/public/interfaces/url_loader_factory.mojom.h" |
| 14 #include "mojo/services/network/public/interfaces/web_socket_factory.mojom.h" | 15 #include "mojo/services/network/public/interfaces/web_socket_factory.mojom.h" |
| 15 #include "mojo/services/tracing/public/cpp/tracing_impl.h" | 16 #include "mojo/services/tracing/public/cpp/tracing_impl.h" |
| 16 #include "mojo/shell/public/cpp/interface_factory.h" | 17 #include "mojo/shell/public/cpp/interface_factory.h" |
| 17 #include "mojo/shell/public/cpp/shell.h" | 18 #include "mojo/shell/public/cpp/message_loop_ref.h" |
| 18 #include "mojo/shell/public/cpp/shell_client.h" | 19 #include "mojo/shell/public/cpp/shell_client.h" |
| 19 | 20 |
| 20 namespace mojo { | 21 namespace mojo { |
| 21 class NetworkServiceDelegateObserver; | 22 class NetworkServiceDelegateObserver; |
| 22 | 23 |
| 23 class NetworkServiceDelegate : public ShellClient, | 24 class NetworkServiceDelegate : public ShellClient, |
| 24 public InterfaceFactory<NetworkService>, | 25 public InterfaceFactory<NetworkService>, |
| 25 public InterfaceFactory<CookieStore>, | 26 public InterfaceFactory<CookieStore>, |
| 26 public InterfaceFactory<WebSocketFactory>, | 27 public InterfaceFactory<WebSocketFactory>, |
| 27 public InterfaceFactory<URLLoaderFactory> { | 28 public InterfaceFactory<URLLoaderFactory> { |
| 28 public: | 29 public: |
| 29 NetworkServiceDelegate(); | 30 NetworkServiceDelegate(); |
| 30 ~NetworkServiceDelegate() override; | 31 ~NetworkServiceDelegate() override; |
| 31 | 32 |
| 32 void AddObserver(NetworkServiceDelegateObserver* observer); | 33 void AddObserver(NetworkServiceDelegateObserver* observer); |
| 33 void RemoveObserver(NetworkServiceDelegateObserver* observer); | 34 void RemoveObserver(NetworkServiceDelegateObserver* observer); |
| 34 | 35 |
| 35 private: | 36 private: |
| 36 // mojo::ShellClient implementation. | 37 // mojo::ShellClient implementation. |
| 37 void Initialize(Shell* shell, const std::string& url, | 38 void Initialize(Connector* connector, const std::string& url, |
| 38 uint32_t id, uint32_t user_id) override; | 39 uint32_t id, uint32_t user_id) override; |
| 39 bool AcceptConnection(Connection* connection) override; | 40 bool AcceptConnection(Connection* connection) override; |
| 40 bool ShellConnectionLost() override; | 41 bool ShellConnectionLost() override; |
| 41 void Quit() override; | |
| 42 | 42 |
| 43 // InterfaceFactory<NetworkService> implementation. | 43 // InterfaceFactory<NetworkService> implementation. |
| 44 void Create(Connection* connection, | 44 void Create(Connection* connection, |
| 45 InterfaceRequest<NetworkService> request) override; | 45 InterfaceRequest<NetworkService> request) override; |
| 46 | 46 |
| 47 // InterfaceFactory<CookieStore> implementation. | 47 // InterfaceFactory<CookieStore> implementation. |
| 48 void Create(Connection* connection, | 48 void Create(Connection* connection, |
| 49 InterfaceRequest<CookieStore> request) override; | 49 InterfaceRequest<CookieStore> request) override; |
| 50 | 50 |
| 51 // InterfaceFactory<WebSocketFactory> implementation. | 51 // InterfaceFactory<WebSocketFactory> implementation. |
| 52 void Create(Connection* connection, | 52 void Create(Connection* connection, |
| 53 InterfaceRequest<WebSocketFactory> request) override; | 53 InterfaceRequest<WebSocketFactory> request) override; |
| 54 | 54 |
| 55 // InterfaceFactory<URLLoaderFactory> implementation. | 55 // InterfaceFactory<URLLoaderFactory> implementation. |
| 56 void Create(Connection* connection, | 56 void Create(Connection* connection, |
| 57 InterfaceRequest<URLLoaderFactory> request) override; | 57 InterfaceRequest<URLLoaderFactory> request) override; |
| 58 | 58 |
| 59 private: | 59 private: |
| 60 Shell* shell_; | 60 void Quit(); |
| 61 |
| 61 mojo::TracingImpl tracing_; | 62 mojo::TracingImpl tracing_; |
| 62 | 63 |
| 63 // Observers that want notifications that our worker thread is going away. | 64 // Observers that want notifications that our worker thread is going away. |
| 64 base::ObserverList<NetworkServiceDelegateObserver> observers_; | 65 base::ObserverList<NetworkServiceDelegateObserver> observers_; |
| 65 | 66 |
| 66 scoped_ptr<NetworkContext> context_; | 67 scoped_ptr<NetworkContext> context_; |
| 68 |
| 69 mojo::MessageLoopRefFactory ref_factory_; |
| 70 |
| 71 DISALLOW_COPY_AND_ASSIGN(NetworkServiceDelegate); |
| 67 }; | 72 }; |
| 68 | 73 |
| 69 } // namespace mojo | 74 } // namespace mojo |
| 70 | 75 |
| 71 #endif // MOJO_SERVICES_NETWORK_NETWORK_SERVICE_DELEGATE_H_ | 76 #endif // MOJO_SERVICES_NETWORK_NETWORK_SERVICE_DELEGATE_H_ |
| OLD | NEW |