Don't preload rarely seen large images
[chromium-blink-merge.git] / components / html_viewer / html_document_application_delegate.h
blob86fcb427207107642be3fae01f8868aea6614f75
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/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "mojo/application/public/cpp/application_delegate.h"
13 #include "mojo/application/public/cpp/application_impl.h"
14 #include "mojo/services/network/public/interfaces/network_service.mojom.h"
15 #include "mojo/services/network/public/interfaces/url_loader_factory.mojom.h"
16 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h"
18 namespace html_viewer {
20 class GlobalState;
21 class HTMLDocument;
22 class HTMLDocumentOOPIF;
24 // ApplicationDelegate created by the content handler for a specific url.
25 class HTMLDocumentApplicationDelegate : public mojo::ApplicationDelegate {
26 public:
27 HTMLDocumentApplicationDelegate(
28 mojo::InterfaceRequest<mojo::Application> request,
29 mojo::URLResponsePtr response,
30 GlobalState* global_state,
31 scoped_ptr<mojo::AppRefCount> parent_app_refcount);
33 private:
34 class ServiceConnectorQueue;
36 ~HTMLDocumentApplicationDelegate() override;
38 // Callback from the quit closure. We key off this rather than
39 // ApplicationDelegate::Quit() as we don't want to shut down the messageloop
40 // when we quit (the messageloop is shared among multiple
41 // HTMLDocumentApplicationDelegates).
42 void OnTerminate();
44 // ApplicationDelegate:
45 void Initialize(mojo::ApplicationImpl* app) override;
46 bool ConfigureIncomingConnection(
47 mojo::ApplicationConnection* connection) override;
49 void OnHTMLDocumentDeleted(HTMLDocument* document);
50 void OnHTMLDocumentDeleted2(HTMLDocumentOOPIF* document);
51 void OnResponseReceived(mojo::URLLoaderPtr loader,
52 mojo::ApplicationConnection* connection,
53 scoped_ptr<ServiceConnectorQueue> connector_queue,
54 mojo::URLResponsePtr response);
56 mojo::ApplicationImpl app_;
57 // AppRefCount of the parent (HTMLViewer).
58 scoped_ptr<mojo::AppRefCount> parent_app_refcount_;
59 const mojo::String url_;
60 mojo::NetworkServicePtr network_service_;
61 mojo::URLLoaderFactoryPtr url_loader_factory_;
62 mojo::URLResponsePtr initial_response_;
63 GlobalState* global_state_;
65 // As we create HTMLDocuments they are added here. They are removed when the
66 // HTMLDocument is deleted.
67 std::set<HTMLDocument*> documents_;
69 // As we create HTMLDocuments they are added here. They are removed when the
70 // HTMLDocument is deleted.
71 std::set<HTMLDocumentOOPIF*> documents2_;
73 DISALLOW_COPY_AND_ASSIGN(HTMLDocumentApplicationDelegate);
76 } // namespace html_viewer
78 #endif // COMPONENTS_HTML_VIEWER_HTML_DOCUMENT_APPLICATION_DELEGATE_H_