Add ICU message format support
[chromium-blink-merge.git] / mojo / services / network / network_service_delegate.h
blob1d87e3ce342be4b2b00836152e3739ab00f1332b
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.
5 #ifndef MOJO_SERVICES_NETWORK_NETWORK_SERVICE_DELEGATE_H_
6 #define MOJO_SERVICES_NETWORK_NETWORK_SERVICE_DELEGATE_H_
8 #include "base/observer_list.h"
9 #include "base/threading/thread.h"
10 #include "components/filesystem/public/interfaces/file_system.mojom.h"
11 #include "mojo/application/public/cpp/application_delegate.h"
12 #include "mojo/application/public/cpp/application_impl.h"
13 #include "mojo/application/public/cpp/interface_factory.h"
14 #include "mojo/services/network/network_context.h"
15 #include "mojo/services/network/public/interfaces/network_service.mojom.h"
16 #include "mojo/services/network/public/interfaces/url_loader_factory.mojom.h"
17 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_ptr.h"
19 namespace sql {
20 class ScopedMojoFilesystemVFS;
23 namespace mojo {
24 class NetworkServiceDelegateObserver;
26 class NetworkServiceDelegate
27 : public mojo::ApplicationDelegate,
28 public mojo::InterfaceFactory<mojo::NetworkService>,
29 public mojo::InterfaceFactory<mojo::URLLoaderFactory>,
30 public filesystem::FileSystemClient {
31 public:
32 NetworkServiceDelegate();
33 ~NetworkServiceDelegate() override;
35 void AddObserver(NetworkServiceDelegateObserver* observer);
36 void RemoveObserver(NetworkServiceDelegateObserver* observer);
38 private:
39 // Notifies all of our observers of a Shuts down our IO thread. Safe to call
40 // multiple times.
41 void EnsureIOThreadShutdown();
43 // mojo::ApplicationDelegate implementation.
44 void Initialize(mojo::ApplicationImpl* app) override;
45 bool ConfigureIncomingConnection(
46 mojo::ApplicationConnection* connection) override;
47 bool OnShellConnectionError() override;
48 void Quit() override;
50 // mojo::InterfaceFactory<mojo::NetworkService> implementation.
51 void Create(mojo::ApplicationConnection* connection,
52 mojo::InterfaceRequest<mojo::NetworkService> request) override;
54 // mojo::InterfaceFactory<mojo::URLLoaderFactory> implementation.
55 void Create(mojo::ApplicationConnection* connection,
56 mojo::InterfaceRequest<mojo::URLLoaderFactory> request) override;
58 // Overridden from FileSystemClient:
59 void OnFileSystemShutdown() override;
61 private:
62 mojo::ApplicationImpl* app_;
64 // Observers that want notifications that our worker thread is going away.
65 base::ObserverList<NetworkServiceDelegateObserver> observers_;
67 mojo::Binding<filesystem::FileSystemClient> binding_;
69 // A worker thread that blocks for file IO.
70 scoped_ptr<base::Thread> io_worker_thread_;
72 // Our connection to the filesystem service, which stores our cookies and
73 // other data.
74 filesystem::FileSystemPtr files_;
76 scoped_ptr<mojo::NetworkContext> context_;
79 } // namespace mojo
81 #endif // MOJO_SERVICES_NETWORK_NETWORK_SERVICE_DELEGATE_H_