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

Side by Side Diff: components/plugins/renderer/webview_plugin.cc

Issue 2349443003: Listen to didReceiveResponse() to get the response in WebViewPlugin. (Closed)
Patch Set: Created 4 years, 3 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/plugins/renderer/webview_plugin.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/plugins/renderer/webview_plugin.h" 5 #include "components/plugins/renderer/webview_plugin.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 } 88 }
89 89
90 WebViewPlugin::~WebViewPlugin() { 90 WebViewPlugin::~WebViewPlugin() {
91 DCHECK(!weak_factory_.HasWeakPtrs()); 91 DCHECK(!weak_factory_.HasWeakPtrs());
92 web_frame_widget_->close(); 92 web_frame_widget_->close();
93 web_view_->close(); 93 web_view_->close();
94 web_frame_->close(); 94 web_frame_->close();
95 } 95 }
96 96
97 void WebViewPlugin::ReplayReceivedData(WebPlugin* plugin) { 97 void WebViewPlugin::ReplayReceivedData(WebPlugin* plugin) {
98 const WebURLResponse& response = web_frame_->dataSource()->response(); 98 if (!response_.isNull()) {
99 if (!response.isNull()) { 99 plugin->didReceiveResponse(response_);
100 plugin->didReceiveResponse(response);
101 size_t total_bytes = 0; 100 size_t total_bytes = 0;
102 for (std::list<std::string>::iterator it = data_.begin(); it != data_.end(); 101 for (std::list<std::string>::iterator it = data_.begin(); it != data_.end();
103 ++it) { 102 ++it) {
104 plugin->didReceiveData( 103 plugin->didReceiveData(
105 it->c_str(), base::checked_cast<int, size_t>(it->length())); 104 it->c_str(), base::checked_cast<int, size_t>(it->length()));
106 total_bytes += it->length(); 105 total_bytes += it->length();
107 } 106 }
108 UMA_HISTOGRAM_MEMORY_KB( 107 UMA_HISTOGRAM_MEMORY_KB(
109 "PluginDocument.Memory", 108 "PluginDocument.Memory",
110 (base::checked_cast<int, size_t>(total_bytes / 1024))); 109 (base::checked_cast<int, size_t>(total_bytes / 1024)));
111 UMA_HISTOGRAM_COUNTS( 110 UMA_HISTOGRAM_COUNTS(
112 "PluginDocument.NumChunks", 111 "PluginDocument.NumChunks",
113 (base::checked_cast<int, size_t>(data_.size()))); 112 (base::checked_cast<int, size_t>(data_.size())));
114 } 113 }
115 // We need to transfer the |focused_| to new plugin after it loaded. 114 // We need to transfer the |focused_| to new plugin after it loaded.
116 if (focused_) { 115 if (focused_) {
117 plugin->updateFocus(true, blink::WebFocusTypeNone); 116 plugin->updateFocus(true, blink::WebFocusTypeNone);
118 } 117 }
119 if (finished_loading_) { 118 if (finished_loading_) {
120 plugin->didFinishLoading(); 119 plugin->didFinishLoading();
121 } 120 }
122 if (error_) { 121 if (error_) {
123 plugin->didFailLoading(*error_); 122 plugin->didFailLoading(*error_);
124 } 123 }
125 } 124 }
126 125
126 void WebViewPlugin::didReceiveResponse(const WebURLResponse& response) {
127 if (!response_.isNull())
tommycli 2016/09/15 23:53:35 This line used to be DCHECK(response_.isNull());
tommycli 2016/09/16 00:01:38 Restoring the old DCHECK crashes, so I'm guessing
Bernhard Bauer 2016/09/16 10:28:01 Huh, that's strange. Where would the non-null valu
Nate Chapin 2016/09/16 17:17:54 Yeah this patchset only works accidentally: I inve
128 response_ = response;
129 }
130
127 void WebViewPlugin::RestoreTitleText() { 131 void WebViewPlugin::RestoreTitleText() {
128 if (container_) 132 if (container_)
129 container_->element().setAttribute("title", old_title_); 133 container_->element().setAttribute("title", old_title_);
130 } 134 }
131 135
132 WebPluginContainer* WebViewPlugin::container() const { return container_; } 136 WebPluginContainer* WebViewPlugin::container() const { return container_; }
133 137
134 bool WebViewPlugin::initialize(WebPluginContainer* container) { 138 bool WebViewPlugin::initialize(WebPluginContainer* container) {
135 DCHECK(container); 139 DCHECK(container);
136 DCHECK_EQ(this, container->plugin()); 140 DCHECK_EQ(this, container->plugin());
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 if (!delegate_) 353 if (!delegate_)
350 return; 354 return;
351 355
352 // The delegate may instantiate a new plugin. 356 // The delegate may instantiate a new plugin.
353 delegate_->OnUnobscuredRectUpdate(gfx::Rect(unobscured_rect)); 357 delegate_->OnUnobscuredRectUpdate(gfx::Rect(unobscured_rect));
354 // The delegate may have dirtied style and layout of the WebView. 358 // The delegate may have dirtied style and layout of the WebView.
355 // See for example the resizePoster function in plugin_poster.html. 359 // See for example the resizePoster function in plugin_poster.html.
356 // Run the lifecycle now so that it is clean. 360 // Run the lifecycle now so that it is clean.
357 web_view_->updateAllLifecyclePhases(); 361 web_view_->updateAllLifecyclePhases();
358 } 362 }
OLDNEW
« no previous file with comments | « components/plugins/renderer/webview_plugin.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698