Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: mojo/services/network/network_service_delegate.h

Issue 1674903003: Extract shell methods from ApplicationImpl into a base class, and pass this to Initialize() instead. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojom
Patch Set: . Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/services/network/network_context.h" 11 #include "mojo/services/network/network_context.h"
12 #include "mojo/services/network/public/interfaces/cookie_store.mojom.h" 12 #include "mojo/services/network/public/interfaces/cookie_store.mojom.h"
13 #include "mojo/services/network/public/interfaces/network_service.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" 14 #include "mojo/services/network/public/interfaces/url_loader_factory.mojom.h"
15 #include "mojo/services/network/public/interfaces/web_socket_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" 16 #include "mojo/services/tracing/public/cpp/tracing_impl.h"
17 #include "mojo/shell/public/cpp/application_delegate.h" 17 #include "mojo/shell/public/cpp/application_delegate.h"
18 #include "mojo/shell/public/cpp/application_impl.h"
19 #include "mojo/shell/public/cpp/interface_factory.h" 18 #include "mojo/shell/public/cpp/interface_factory.h"
19 #include "mojo/shell/public/cpp/shell.h"
20 20
21 namespace sql { 21 namespace sql {
22 class ScopedMojoFilesystemVFS; 22 class ScopedMojoFilesystemVFS;
23 } 23 }
24 24
25 namespace mojo { 25 namespace mojo {
26 class NetworkServiceDelegateObserver; 26 class NetworkServiceDelegateObserver;
27 27
28 class NetworkServiceDelegate : public ApplicationDelegate, 28 class NetworkServiceDelegate : public ApplicationDelegate,
29 public InterfaceFactory<NetworkService>, 29 public InterfaceFactory<NetworkService>,
30 public InterfaceFactory<CookieStore>, 30 public InterfaceFactory<CookieStore>,
31 public InterfaceFactory<WebSocketFactory>, 31 public InterfaceFactory<WebSocketFactory>,
32 public InterfaceFactory<URLLoaderFactory>, 32 public InterfaceFactory<URLLoaderFactory>,
33 public filesystem::FileSystemClient { 33 public filesystem::FileSystemClient {
34 public: 34 public:
35 NetworkServiceDelegate(); 35 NetworkServiceDelegate();
36 ~NetworkServiceDelegate() override; 36 ~NetworkServiceDelegate() override;
37 37
38 void AddObserver(NetworkServiceDelegateObserver* observer); 38 void AddObserver(NetworkServiceDelegateObserver* observer);
39 void RemoveObserver(NetworkServiceDelegateObserver* observer); 39 void RemoveObserver(NetworkServiceDelegateObserver* observer);
40 40
41 private: 41 private:
42 // Notifies all of our observers of a Shuts down our IO thread. Safe to call 42 // Notifies all of our observers of a Shuts down our IO thread. Safe to call
43 // multiple times. 43 // multiple times.
44 void EnsureIOThreadShutdown(); 44 void EnsureIOThreadShutdown();
45 45
46 // ApplicationDelegate implementation. 46 // ApplicationDelegate implementation.
47 void Initialize(ApplicationImpl* app) override; 47 void Initialize(Shell* shell, const std::string& url, uint32_t id) override;
48 bool AcceptConnection(ApplicationConnection* connection) override; 48 bool AcceptConnection(ApplicationConnection* connection) override;
49 bool ShellConnectionLost() override; 49 bool ShellConnectionLost() override;
50 void Quit() override; 50 void Quit() override;
51 51
52 // InterfaceFactory<NetworkService> implementation. 52 // InterfaceFactory<NetworkService> implementation.
53 void Create(ApplicationConnection* connection, 53 void Create(ApplicationConnection* connection,
54 InterfaceRequest<NetworkService> request) override; 54 InterfaceRequest<NetworkService> request) override;
55 55
56 // InterfaceFactory<CookieStore> implementation. 56 // InterfaceFactory<CookieStore> implementation.
57 void Create(ApplicationConnection* connection, 57 void Create(ApplicationConnection* connection,
58 InterfaceRequest<CookieStore> request) override; 58 InterfaceRequest<CookieStore> request) override;
59 59
60 // InterfaceFactory<WebSocketFactory> implementation. 60 // InterfaceFactory<WebSocketFactory> implementation.
61 void Create(ApplicationConnection* connection, 61 void Create(ApplicationConnection* connection,
62 InterfaceRequest<WebSocketFactory> request) override; 62 InterfaceRequest<WebSocketFactory> request) override;
63 63
64 // InterfaceFactory<URLLoaderFactory> implementation. 64 // InterfaceFactory<URLLoaderFactory> implementation.
65 void Create(ApplicationConnection* connection, 65 void Create(ApplicationConnection* connection,
66 InterfaceRequest<URLLoaderFactory> request) override; 66 InterfaceRequest<URLLoaderFactory> request) override;
67 67
68 // Overridden from FileSystemClient: 68 // Overridden from FileSystemClient:
69 void OnFileSystemShutdown() override; 69 void OnFileSystemShutdown() override;
70 70
71 private: 71 private:
72 ApplicationImpl* app_; 72 Shell* shell_;
73 mojo::TracingImpl tracing_; 73 mojo::TracingImpl tracing_;
74 74
75 // Observers that want notifications that our worker thread is going away. 75 // Observers that want notifications that our worker thread is going away.
76 base::ObserverList<NetworkServiceDelegateObserver> observers_; 76 base::ObserverList<NetworkServiceDelegateObserver> observers_;
77 77
78 Binding<filesystem::FileSystemClient> binding_; 78 Binding<filesystem::FileSystemClient> binding_;
79 79
80 // A worker thread that blocks for file IO. 80 // A worker thread that blocks for file IO.
81 scoped_ptr<base::Thread> io_worker_thread_; 81 scoped_ptr<base::Thread> io_worker_thread_;
82 82
83 // Our connection to the filesystem service, which stores our cookies and 83 // Our connection to the filesystem service, which stores our cookies and
84 // other data. 84 // other data.
85 filesystem::FileSystemPtr files_; 85 filesystem::FileSystemPtr files_;
86 86
87 scoped_ptr<NetworkContext> context_; 87 scoped_ptr<NetworkContext> context_;
88 }; 88 };
89 89
90 } // namespace mojo 90 } // namespace mojo
91 91
92 #endif // MOJO_SERVICES_NETWORK_NETWORK_SERVICE_DELEGATE_H_ 92 #endif // MOJO_SERVICES_NETWORK_NETWORK_SERVICE_DELEGATE_H_
OLDNEW
« no previous file with comments | « mojo/services/network/http_server_apptest.cc ('k') | mojo/services/network/network_service_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698