Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: components/html_viewer/document_resource_waiter.cc

Issue 1414663002: Mandoline webview: View => Window (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More renaming Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/html_viewer/document_resource_waiter.h ('k') | components/html_viewer/html_frame.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/html_viewer/document_resource_waiter.h" 5 #include "components/html_viewer/document_resource_waiter.h"
6 6
7 #include "components/html_viewer/global_state.h" 7 #include "components/html_viewer/global_state.h"
8 #include "components/html_viewer/html_document.h" 8 #include "components/html_viewer/html_document.h"
9 #include "components/html_viewer/html_frame_tree_manager.h" 9 #include "components/html_viewer/html_frame_tree_manager.h"
10 #include "components/mus/public/cpp/window.h" 10 #include "components/mus/public/cpp/window.h"
11 11
12 using web_view::mojom::ViewConnectType; 12 using web_view::mojom::WindowConnectType;
13 13
14 namespace html_viewer { 14 namespace html_viewer {
15 15
16 DocumentResourceWaiter::DocumentResourceWaiter(GlobalState* global_state, 16 DocumentResourceWaiter::DocumentResourceWaiter(GlobalState* global_state,
17 mojo::URLResponsePtr response, 17 mojo::URLResponsePtr response,
18 HTMLDocument* document) 18 HTMLDocument* document)
19 : global_state_(global_state), 19 : global_state_(global_state),
20 document_(document), 20 document_(document),
21 response_(response.Pass()), 21 response_(response.Pass()),
22 root_(nullptr), 22 root_(nullptr),
23 change_id_(0u), 23 change_id_(0u),
24 window_id_(0u), 24 window_id_(0u),
25 view_connect_type_(web_view::mojom::VIEW_CONNECT_TYPE_USE_NEW), 25 window_connect_type_(web_view::mojom::WINDOW_CONNECT_TYPE_USE_NEW),
26 frame_client_binding_(this), 26 frame_client_binding_(this),
27 is_ready_(false), 27 is_ready_(false),
28 waiting_for_change_id_(false), 28 waiting_for_change_id_(false),
29 target_frame_tree_(nullptr) {} 29 target_frame_tree_(nullptr) {}
30 30
31 DocumentResourceWaiter::~DocumentResourceWaiter() { 31 DocumentResourceWaiter::~DocumentResourceWaiter() {
32 if (root_) 32 if (root_)
33 root_->RemoveObserver(this); 33 root_->RemoveObserver(this);
34 if (target_frame_tree_) 34 if (target_frame_tree_)
35 target_frame_tree_->RemoveObserver(this); 35 target_frame_tree_->RemoveObserver(this);
36 } 36 }
37 37
38 void DocumentResourceWaiter::Release( 38 void DocumentResourceWaiter::Release(
39 mojo::InterfaceRequest<web_view::mojom::FrameClient>* frame_client_request, 39 mojo::InterfaceRequest<web_view::mojom::FrameClient>* frame_client_request,
40 web_view::mojom::FramePtr* frame, 40 web_view::mojom::FramePtr* frame,
41 mojo::Array<web_view::mojom::FrameDataPtr>* frame_data, 41 mojo::Array<web_view::mojom::FrameDataPtr>* frame_data,
42 uint32_t* change_id, 42 uint32_t* change_id,
43 uint32_t* window_id, 43 uint32_t* window_id,
44 ViewConnectType* view_connect_type, 44 WindowConnectType* window_connect_type,
45 OnConnectCallback* on_connect_callback) { 45 OnConnectCallback* on_connect_callback) {
46 DCHECK(is_ready_); 46 DCHECK(is_ready_);
47 *frame_client_request = frame_client_request_.Pass(); 47 *frame_client_request = frame_client_request_.Pass();
48 *frame = frame_.Pass(); 48 *frame = frame_.Pass();
49 *frame_data = frame_data_.Pass(); 49 *frame_data = frame_data_.Pass();
50 *change_id = change_id_; 50 *change_id = change_id_;
51 *window_id = window_id_; 51 *window_id = window_id_;
52 *view_connect_type = view_connect_type_; 52 *window_connect_type = window_connect_type_;
53 *on_connect_callback = on_connect_callback_; 53 *on_connect_callback = on_connect_callback_;
54 } 54 }
55 55
56 mojo::URLResponsePtr DocumentResourceWaiter::ReleaseURLResponse() { 56 mojo::URLResponsePtr DocumentResourceWaiter::ReleaseURLResponse() {
57 return response_.Pass(); 57 return response_.Pass();
58 } 58 }
59 59
60 void DocumentResourceWaiter::SetRoot(mus::Window* root) { 60 void DocumentResourceWaiter::SetRoot(mus::Window* root) {
61 DCHECK(!root_); 61 DCHECK(!root_);
62 root_ = root; 62 root_ = root;
(...skipping 19 matching lines...) Expand all
82 if (target_frame_tree_->change_id() == change_id_) { 82 if (target_frame_tree_->change_id() == change_id_) {
83 is_ready_ = true; 83 is_ready_ = true;
84 waiting_for_change_id_ = false; 84 waiting_for_change_id_ = false;
85 document_->Load(); 85 document_->Load();
86 } 86 }
87 return; 87 return;
88 } 88 }
89 89
90 // The first portion of ready is when we have received OnConnect() 90 // The first portion of ready is when we have received OnConnect()
91 // (|frame_data_| is valid) and we have a window with valid metrics. The 91 // (|frame_data_| is valid) and we have a window with valid metrics. The
92 // window is not necessary is ViewConnectType is USE_EXISTING, which means the 92 // window is not necessary is WindowConnectType is USE_EXISTING, which means
93 // the
93 // application is not asked for a ViewTreeClient. The metrics are necessary 94 // application is not asked for a ViewTreeClient. The metrics are necessary
94 // to initialize ResourceBundle. If USE_EXISTING is true, it means a Window 95 // to initialize ResourceBundle. If USE_EXISTING is true, it means a Window
95 // has already been provided to another HTMLDocument and there is no need to 96 // has already been provided to another HTMLDocument and there is no need to
96 // wait for metrics. 97 // wait for metrics.
97 bool is_ready = 98 bool is_ready =
98 (!frame_data_.is_null() && 99 (!frame_data_.is_null() &&
99 ((view_connect_type_ == 100 ((window_connect_type_ ==
100 web_view::mojom::VIEW_CONNECT_TYPE_USE_EXISTING) || 101 web_view::mojom::WINDOW_CONNECT_TYPE_USE_EXISTING) ||
101 (root_ && root_->viewport_metrics().device_pixel_ratio != 0.0f))); 102 (root_ && root_->viewport_metrics().device_pixel_ratio != 0.0f)));
102 if (is_ready) { 103 if (is_ready) {
103 HTMLFrameTreeManager* frame_tree = 104 HTMLFrameTreeManager* frame_tree =
104 HTMLFrameTreeManager::FindFrameTreeWithRoot(frame_data_[0]->frame_id); 105 HTMLFrameTreeManager::FindFrameTreeWithRoot(frame_data_[0]->frame_id);
105 // Once we've received OnConnect() and the window (if necessary), we 106 // Once we've received OnConnect() and the window (if necessary), we
106 // determine which HTMLFrameTreeManager the new frame ends up in. If there 107 // determine which HTMLFrameTreeManager the new frame ends up in. If there
107 // is an existing HTMLFrameTreeManager then we must wait for the change_id 108 // is an existing HTMLFrameTreeManager then we must wait for the change_id
108 // supplied to OnConnect() to be <= that of the HTMLFrameTreeManager's 109 // supplied to OnConnect() to be <= that of the HTMLFrameTreeManager's
109 // change_id. If we did not wait for the change id to be <= then the 110 // change_id. If we did not wait for the change id to be <= then the
110 // structure of the tree is not in the expected state and it's possible the 111 // structure of the tree is not in the expected state and it's possible the
111 // frame communicated in OnConnect() does not exist yet. 112 // frame communicated in OnConnect() does not exist yet.
112 if (frame_tree && change_id_ > frame_tree->change_id()) { 113 if (frame_tree && change_id_ > frame_tree->change_id()) {
113 waiting_for_change_id_ = true; 114 waiting_for_change_id_ = true;
114 target_frame_tree_ = frame_tree; 115 target_frame_tree_ = frame_tree;
115 target_frame_tree_->AddObserver(this); 116 target_frame_tree_->AddObserver(this);
116 } else { 117 } else {
117 is_ready_ = true; 118 is_ready_ = true;
118 document_->Load(); 119 document_->Load();
119 } 120 }
120 } 121 }
121 } 122 }
122 123
123 void DocumentResourceWaiter::OnConnect( 124 void DocumentResourceWaiter::OnConnect(
124 web_view::mojom::FramePtr frame, 125 web_view::mojom::FramePtr frame,
125 uint32_t change_id, 126 uint32_t change_id,
126 uint32_t window_id, 127 uint32_t window_id,
127 ViewConnectType view_connect_type, 128 WindowConnectType window_connect_type,
128 mojo::Array<web_view::mojom::FrameDataPtr> frame_data, 129 mojo::Array<web_view::mojom::FrameDataPtr> frame_data,
129 int64_t navigation_start_time_ticks, 130 int64_t navigation_start_time_ticks,
130 const OnConnectCallback& callback) { 131 const OnConnectCallback& callback) {
131 DCHECK(frame_data_.is_null()); 132 DCHECK(frame_data_.is_null());
132 change_id_ = change_id; 133 change_id_ = change_id;
133 window_id_ = window_id; 134 window_id_ = window_id;
134 view_connect_type_ = view_connect_type; 135 window_connect_type_ = window_connect_type;
135 frame_ = frame.Pass(); 136 frame_ = frame.Pass();
136 frame_data_ = frame_data.Pass(); 137 frame_data_ = frame_data.Pass();
137 navigation_start_time_ = 138 navigation_start_time_ =
138 base::TimeTicks::FromInternalValue(navigation_start_time_ticks); 139 base::TimeTicks::FromInternalValue(navigation_start_time_ticks);
139 on_connect_callback_ = callback; 140 on_connect_callback_ = callback;
140 CHECK(frame_data_.size() > 0u); 141 CHECK(frame_data_.size() > 0u);
141 frame_client_request_ = frame_client_binding_.Unbind(); 142 frame_client_request_ = frame_client_binding_.Unbind();
142 UpdateIsReady(); 143 UpdateIsReady();
143 } 144 }
144 145
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 232
232 void DocumentResourceWaiter::OnHTMLFrameTreeManagerChangeIdAdvanced() { 233 void DocumentResourceWaiter::OnHTMLFrameTreeManagerChangeIdAdvanced() {
233 UpdateIsReady(); 234 UpdateIsReady();
234 } 235 }
235 236
236 void DocumentResourceWaiter::OnHTMLFrameTreeManagerDestroyed() { 237 void DocumentResourceWaiter::OnHTMLFrameTreeManagerDestroyed() {
237 document_->Destroy(); // This destroys us. 238 document_->Destroy(); // This destroys us.
238 } 239 }
239 240
240 } // namespace html_viewer 241 } // namespace html_viewer
OLDNEW
« no previous file with comments | « components/html_viewer/document_resource_waiter.h ('k') | components/html_viewer/html_frame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698