Add long running gmail memory benchmark for background tab.
[chromium-blink-merge.git] / components / html_viewer / html_document_application_delegate.h
blob83f25a853853c7a5da8659b8cbb79e1b8d100e81
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 COMPONENTS_HTML_VIEWER_HTML_DOCUMENT_APPLICATION_DELEGATE_H_
6 #define COMPONENTS_HTML_VIEWER_HTML_DOCUMENT_APPLICATION_DELEGATE_H_
8 #include <set>
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "components/html_viewer/html_document.h"
14 #include "mojo/application/public/cpp/application_delegate.h"
15 #include "mojo/application/public/cpp/application_impl.h"
16 #include "mojo/services/network/public/interfaces/network_service.mojom.h"
17 #include "mojo/services/network/public/interfaces/url_loader_factory.mojom.h"
18 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h"
20 namespace html_viewer {
22 class GlobalState;
23 class HTMLDocumentOOPIF;
25 // ApplicationDelegate created by the content handler for a specific url.
26 class HTMLDocumentApplicationDelegate : public mojo::ApplicationDelegate {
27 public:
28 HTMLDocumentApplicationDelegate(
29 mojo::InterfaceRequest<mojo::Application> request,
30 mojo::URLResponsePtr response,
31 GlobalState* global_state,
32 scoped_ptr<mojo::AppRefCount> parent_app_refcount);
34 typedef base::Callback<HTMLDocument*(HTMLDocument::CreateParams*)>
35 HTMLDocumentCreationCallback;
37 void SetHTMLDocumentCreationCallback(
38 const HTMLDocumentCreationCallback& callback);
40 private:
41 class ServiceConnectorQueue;
43 ~HTMLDocumentApplicationDelegate() override;
45 // Callback from the quit closure. We key off this rather than
46 // ApplicationDelegate::Quit() as we don't want to shut down the messageloop
47 // when we quit (the messageloop is shared among multiple
48 // HTMLDocumentApplicationDelegates).
49 void OnTerminate();
51 // ApplicationDelegate:
52 void Initialize(mojo::ApplicationImpl* app) override;
53 bool ConfigureIncomingConnection(
54 mojo::ApplicationConnection* connection) override;
56 void OnHTMLDocumentDeleted(HTMLDocument* document);
57 void OnHTMLDocumentDeleted2(HTMLDocumentOOPIF* document);
58 void OnResponseReceived(mojo::URLLoaderPtr loader,
59 mojo::ApplicationConnection* connection,
60 scoped_ptr<ServiceConnectorQueue> connector_queue,
61 mojo::URLResponsePtr response);
63 mojo::ApplicationImpl app_;
64 // AppRefCount of the parent (HTMLViewer).
65 scoped_ptr<mojo::AppRefCount> parent_app_refcount_;
66 const mojo::String url_;
67 mojo::NetworkServicePtr network_service_;
68 mojo::URLLoaderFactoryPtr url_loader_factory_;
69 mojo::URLResponsePtr initial_response_;
70 GlobalState* global_state_;
72 // As we create HTMLDocuments they are added here. They are removed when the
73 // HTMLDocument is deleted.
74 std::set<HTMLDocument*> documents_;
76 // As we create HTMLDocuments they are added here. They are removed when the
77 // HTMLDocument is deleted.
78 std::set<HTMLDocumentOOPIF*> documents2_;
80 HTMLDocumentCreationCallback html_document_creation_callback_;
82 DISALLOW_COPY_AND_ASSIGN(HTMLDocumentApplicationDelegate);
85 } // namespace html_viewer
87 #endif // COMPONENTS_HTML_VIEWER_HTML_DOCUMENT_APPLICATION_DELEGATE_H_