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

Side by Side Diff: webkit/glue/plugins/webview_plugin.cc

Issue 3038027: Record received data in WebViewPlugin and replay it when loading the real plugin. (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: . Created 10 years, 4 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 | « webkit/glue/plugins/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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "webkit/glue/plugins/webview_plugin.h" 5 #include "webkit/glue/plugins/webview_plugin.h"
6 6
7 #include "base/histogram.h"
7 #include "base/message_loop.h" 8 #include "base/message_loop.h"
8 #include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h" 9 #include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h"
9 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" 10 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
10 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h" 11 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h"
11 #include "third_party/WebKit/WebKit/chromium/public/WebSettings.h" 12 #include "third_party/WebKit/WebKit/chromium/public/WebSettings.h"
12 #include "third_party/WebKit/WebKit/chromium/public/WebSize.h" 13 #include "third_party/WebKit/WebKit/chromium/public/WebSize.h"
13 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" 14 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
14 #include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h" 15 #include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h"
15 #include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h" 16 #include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h"
16 #include "third_party/WebKit/WebKit/chromium/public/WebView.h" 17 #include "third_party/WebKit/WebKit/chromium/public/WebView.h"
(...skipping 28 matching lines...) Expand all
45 finished_loading_(false) { 46 finished_loading_(false) {
46 web_view_ = WebView::create(this, NULL); 47 web_view_ = WebView::create(this, NULL);
47 web_view_->initializeMainFrame(this); 48 web_view_->initializeMainFrame(this);
48 } 49 }
49 50
50 WebViewPlugin::~WebViewPlugin() { 51 WebViewPlugin::~WebViewPlugin() {
51 web_view_->close(); 52 web_view_->close();
52 } 53 }
53 54
54 void WebViewPlugin::ReplayReceivedData(WebPlugin* plugin) { 55 void WebViewPlugin::ReplayReceivedData(WebPlugin* plugin) {
55 if (response_.get()) { 56 if (!response_.isNull()) {
56 plugin->didReceiveResponse(*response_); 57 plugin->didReceiveResponse(response_);
57 plugin->didReceiveData(data_.c_str(), data_.length()); 58 size_t total_bytes = 0;
59 for (std::list<std::string>::iterator it = data_.begin();
60 it != data_.end(); ++it) {
61 plugin->didReceiveData(it->c_str(), it->length());
62 total_bytes += it->length();
63 }
64 UMA_HISTOGRAM_MEMORY_KB("PluginDocument.Memory", (total_bytes / 1024));
65 UMA_HISTOGRAM_COUNTS("PluginDocument.NumChunks", data_.size());
58 } 66 }
59 if (finished_loading_) { 67 if (finished_loading_) {
60 plugin->didFinishLoading(); 68 plugin->didFinishLoading();
61 } 69 }
62 if (error_.get()) { 70 if (error_.get()) {
63 plugin->didFailLoading(*error_); 71 plugin->didFailLoading(*error_);
64 } 72 }
65 } 73 }
66 74
67 bool WebViewPlugin::initialize(WebPluginContainer* container) { 75 bool WebViewPlugin::initialize(WebPluginContainer* container) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 124
117 bool WebViewPlugin::handleInputEvent(const WebInputEvent& event, 125 bool WebViewPlugin::handleInputEvent(const WebInputEvent& event,
118 WebCursorInfo& cursor) { 126 WebCursorInfo& cursor) {
119 current_cursor_ = cursor; 127 current_cursor_ = cursor;
120 bool handled = web_view_->handleInputEvent(event); 128 bool handled = web_view_->handleInputEvent(event);
121 cursor = current_cursor_; 129 cursor = current_cursor_;
122 return handled; 130 return handled;
123 } 131 }
124 132
125 void WebViewPlugin::didReceiveResponse(const WebURLResponse& response) { 133 void WebViewPlugin::didReceiveResponse(const WebURLResponse& response) {
126 DCHECK(!response_.get()); 134 DCHECK(response_.isNull());
127 response_.reset(new WebURLResponse(response)); 135 response_ = response;
128 } 136 }
129 137
130 void WebViewPlugin::didReceiveData(const char* data, int data_length) { 138 void WebViewPlugin::didReceiveData(const char* data, int data_length) {
131 data_.append(data, data_length); 139 data_.push_back(std::string(data, data_length));
132 } 140 }
133 141
134 void WebViewPlugin::didFinishLoading() { 142 void WebViewPlugin::didFinishLoading() {
135 DCHECK(!finished_loading_); 143 DCHECK(!finished_loading_);
136 finished_loading_ = true; 144 finished_loading_ = true;
137 } 145 }
138 146
139 void WebViewPlugin::didFailLoading(const WebURLError& error) { 147 void WebViewPlugin::didFailLoading(const WebURLError& error) {
140 DCHECK(!error_.get()); 148 DCHECK(!error_.get());
141 error_.reset(new WebURLError(error)); 149 error_.reset(new WebURLError(error));
(...skipping 29 matching lines...) Expand all
171 WebURLError WebViewPlugin::cancelledError(WebFrame* frame, 179 WebURLError WebViewPlugin::cancelledError(WebFrame* frame,
172 const WebURLRequest& request) { 180 const WebURLRequest& request) {
173 // Return an error with a non-zero reason so isNull() on the corresponding 181 // Return an error with a non-zero reason so isNull() on the corresponding
174 // ResourceError is false. 182 // ResourceError is false.
175 WebURLError error; 183 WebURLError error;
176 error.domain = "WebViewPlugin"; 184 error.domain = "WebViewPlugin";
177 error.reason = -1; 185 error.reason = -1;
178 error.unreachableURL = request.url(); 186 error.unreachableURL = request.url();
179 return error; 187 return error;
180 } 188 }
OLDNEW
« no previous file with comments | « webkit/glue/plugins/webview_plugin.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698