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