Revert "Fix broken channel icon in chrome://help on CrOS" and try again
[chromium-blink-merge.git] / components / html_viewer / document_resource_waiter.h
bloba2312e45a6dd8fa4ee91c2429563c8343fe36830
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_DOCUMENT_RESOURCE_WAITER_H_
6 #define COMPONENTS_HTML_VIEWER_DOCUMENT_RESOURCE_WAITER_H_
8 #include "base/basictypes.h"
9 #include "mandoline/tab/public/interfaces/frame_tree.mojom.h"
10 #include "mojo/services/network/public/interfaces/url_loader.mojom.h"
11 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h"
13 namespace mojo {
14 class View;
17 namespace html_viewer {
19 class HTMLDocumentOOPIF;
20 class GlobalState;
22 // DocumentResourceWaiter waits for the necessary resources needed to load an
23 // HTMLDocument. Use IsReady() to determine when everything is available. Once
24 // ready it is assumed HTMLDocument will call back for the FrameTreeClient and
25 // FrameData.
26 class DocumentResourceWaiter : public mandoline::FrameTreeClient {
27 public:
28 DocumentResourceWaiter(GlobalState* global_state,
29 mojo::URLResponsePtr response,
30 HTMLDocumentOOPIF* document);
31 ~DocumentResourceWaiter() override;
33 // Releases all the resources that have been accumulated.
34 void Release(mojo::InterfaceRequest<mandoline::FrameTreeClient>*
35 frame_tree_client_request,
36 mandoline::FrameTreeServerPtr* frame_tree_server,
37 mojo::Array<mandoline::FrameDataPtr>* frame_data,
38 uint32_t* change_id);
40 mojo::URLResponsePtr ReleaseURLResponse();
42 // See class description.
43 bool IsReady() const;
45 void set_root(mojo::View* root) { root_ = root; }
46 mojo::View* root() { return root_; }
48 void Bind(mojo::InterfaceRequest<mandoline::FrameTreeClient> request);
50 private:
51 // mandoline::FrameTreeClient:
52 void OnConnect(mandoline::FrameTreeServerPtr server,
53 uint32_t change_id,
54 mojo::Array<mandoline::FrameDataPtr> frame_data) override;
55 void OnFrameAdded(uint32_t change_id,
56 mandoline::FrameDataPtr frame_data) override;
57 void OnFrameRemoved(uint32_t change_id, uint32_t frame_id) override;
58 void OnFrameClientPropertyChanged(uint32_t frame_id,
59 const mojo::String& name,
60 mojo::Array<uint8_t> new_value) override;
61 void OnPostMessageEvent(uint32_t source_frame_id,
62 uint32_t target_frame_id,
63 mandoline::HTMLMessageEventPtr event) override;
64 void OnWillNavigate(uint32_t target_frame_id,
65 const OnWillNavigateCallback& callback) override;
67 GlobalState* global_state_;
68 HTMLDocumentOOPIF* document_;
69 mojo::URLResponsePtr response_;
70 mojo::View* root_;
71 mandoline::FrameTreeServerPtr server_;
72 mojo::Array<mandoline::FrameDataPtr> frame_data_;
73 uint32_t change_id_;
75 // Once we get OnConnect() we unbind |frame_tree_client_binding_| and put it
76 // here.
77 mojo::InterfaceRequest<mandoline::FrameTreeClient> frame_tree_client_request_;
78 mojo::Binding<mandoline::FrameTreeClient> frame_tree_client_binding_;
80 DISALLOW_COPY_AND_ASSIGN(DocumentResourceWaiter);
83 } // namespace html_viewer
85 #endif // COMPONENTS_HTML_VIEWER_DOCUMENT_RESOURCE_WAITER_H_