Stack sampling profiler: add fire-and-forget interface
[chromium-blink-merge.git] / components / html_viewer / document_resource_waiter.h
blob784e9353633798417fc8fc525da07322de3a9b3c
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"
12 namespace mojo {
13 class View;
16 namespace html_viewer {
18 class HTMLDocumentOOPIF;
19 class GlobalState;
21 // DocumentResourceWaiter waits for the necessary resources needed to load an
22 // HTMLDocument. Use IsReady() to determine when everything is available. Once
23 // ready it is assumed HTMLDocument will call back for the FrameTreeClient and
24 // FrameData.
25 class DocumentResourceWaiter : public mandoline::FrameTreeClient {
26 public:
27 DocumentResourceWaiter(GlobalState* global_state,
28 mojo::URLResponsePtr response,
29 HTMLDocumentOOPIF* document);
30 ~DocumentResourceWaiter() override;
32 // Releases all the resources that have been accumulated.
33 void Release(mojo::InterfaceRequest<mandoline::FrameTreeClient>*
34 frame_tree_client_request,
35 mandoline::FrameTreeServerPtr* frame_tree_server,
36 mojo::Array<mandoline::FrameDataPtr>* frame_data);
38 mojo::URLResponsePtr ReleaseURLResponse();
40 // See class description.
41 bool IsReady() const;
43 void set_root(mojo::View* root) { root_ = root; }
44 mojo::View* root() { return root_; }
46 void Bind(mojo::InterfaceRequest<mandoline::FrameTreeClient> request);
48 private:
49 // mandoline::FrameTreeClient:
50 void OnConnect(mandoline::FrameTreeServerPtr server,
51 mojo::Array<mandoline::FrameDataPtr> frame_data) override;
52 void OnFrameAdded(mandoline::FrameDataPtr frame_data) override;
53 void OnFrameRemoved(uint32_t frame_id) override;
54 void OnFrameNameChanged(uint32_t frame_id, const mojo::String& name) override;
56 GlobalState* global_state_;
57 HTMLDocumentOOPIF* document_;
58 mojo::URLResponsePtr response_;
59 mojo::View* root_;
60 mandoline::FrameTreeServerPtr server_;
61 mojo::Array<mandoline::FrameDataPtr> frame_data_;
63 // Once we get OnConnect() we unbind |frame_tree_client_binding_| and put it
64 // here.
65 mojo::InterfaceRequest<mandoline::FrameTreeClient> frame_tree_client_request_;
66 mojo::Binding<mandoline::FrameTreeClient> frame_tree_client_binding_;
68 DISALLOW_COPY_AND_ASSIGN(DocumentResourceWaiter);
71 } // namespace html_viewer
73 #endif // COMPONENTS_HTML_VIEWER_DOCUMENT_RESOURCE_WAITER_H_