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

Side by Side Diff: content/renderer/pepper/pepper_webplugin_impl.cc

Issue 849723002: Plugin Power Saver: Make PepperPluginInstanceThrottler interface public. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/renderer/pepper/pepper_webplugin_impl.h" 5 #include "content/renderer/pepper/pepper_webplugin_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/debug/crash_logging.h" 9 #include "base/debug/crash_logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "content/public/common/page_zoom.h" 11 #include "content/public/common/page_zoom.h"
12 #include "content/public/renderer/content_renderer_client.h" 12 #include "content/public/renderer/content_renderer_client.h"
13 #include "content/renderer/pepper/message_channel.h" 13 #include "content/renderer/pepper/message_channel.h"
14 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" 14 #include "content/renderer/pepper/pepper_plugin_instance_impl.h"
15 #include "content/renderer/pepper/plugin_instance_throttler_impl.h"
15 #include "content/renderer/pepper/plugin_module.h" 16 #include "content/renderer/pepper/plugin_module.h"
16 #include "content/renderer/pepper/v8object_var.h" 17 #include "content/renderer/pepper/v8object_var.h"
17 #include "content/renderer/render_frame_impl.h" 18 #include "content/renderer/render_frame_impl.h"
18 #include "ppapi/shared_impl/ppapi_globals.h" 19 #include "ppapi/shared_impl/ppapi_globals.h"
19 #include "ppapi/shared_impl/var_tracker.h" 20 #include "ppapi/shared_impl/var_tracker.h"
20 #include "third_party/WebKit/public/platform/WebPoint.h" 21 #include "third_party/WebKit/public/platform/WebPoint.h"
21 #include "third_party/WebKit/public/platform/WebRect.h" 22 #include "third_party/WebKit/public/platform/WebRect.h"
22 #include "third_party/WebKit/public/platform/WebSize.h" 23 #include "third_party/WebKit/public/platform/WebSize.h"
23 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" 24 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
24 #include "third_party/WebKit/public/web/WebBindings.h" 25 #include "third_party/WebKit/public/web/WebBindings.h"
(...skipping 27 matching lines...) Expand all
52 RenderFrameImpl* render_frame; 53 RenderFrameImpl* render_frame;
53 std::vector<std::string> arg_names; 54 std::vector<std::string> arg_names;
54 std::vector<std::string> arg_values; 55 std::vector<std::string> arg_values;
55 GURL url; 56 GURL url;
56 }; 57 };
57 58
58 PepperWebPluginImpl::PepperWebPluginImpl( 59 PepperWebPluginImpl::PepperWebPluginImpl(
59 PluginModule* plugin_module, 60 PluginModule* plugin_module,
60 const WebPluginParams& params, 61 const WebPluginParams& params,
61 RenderFrameImpl* render_frame, 62 RenderFrameImpl* render_frame,
62 RenderFrame::PluginPowerSaverMode power_saver_mode) 63 scoped_ptr<PluginInstanceThrottlerImpl> throttler)
63 : init_data_(new InitData()), 64 : init_data_(new InitData()),
64 full_frame_(params.loadManually), 65 full_frame_(params.loadManually),
65 power_saver_mode_(power_saver_mode), 66 throttler_(throttler.Pass()),
66 instance_object_(PP_MakeUndefined()), 67 instance_object_(PP_MakeUndefined()),
67 container_(NULL) { 68 container_(NULL) {
68 DCHECK(plugin_module); 69 DCHECK(plugin_module);
69 init_data_->module = plugin_module; 70 init_data_->module = plugin_module;
70 init_data_->render_frame = render_frame; 71 init_data_->render_frame = render_frame;
71 for (size_t i = 0; i < params.attributeNames.size(); ++i) { 72 for (size_t i = 0; i < params.attributeNames.size(); ++i) {
72 init_data_->arg_names.push_back(params.attributeNames[i].utf8()); 73 init_data_->arg_names.push_back(params.attributeNames[i].utf8());
73 init_data_->arg_values.push_back(params.attributeValues[i].utf8()); 74 init_data_->arg_values.push_back(params.attributeValues[i].utf8());
74 } 75 }
75 init_data_->url = params.url; 76 init_data_->url = params.url;
(...skipping 13 matching lines...) Expand all
89 instance_ = init_data_->module->CreateInstance( 90 instance_ = init_data_->module->CreateInstance(
90 init_data_->render_frame, container, init_data_->url); 91 init_data_->render_frame, container, init_data_->url);
91 if (!instance_.get()) 92 if (!instance_.get())
92 return false; 93 return false;
93 94
94 // Enable script objects for this plugin. 95 // Enable script objects for this plugin.
95 container->allowScriptObjects(); 96 container->allowScriptObjects();
96 97
97 bool success = 98 bool success =
98 instance_->Initialize(init_data_->arg_names, init_data_->arg_values, 99 instance_->Initialize(init_data_->arg_names, init_data_->arg_values,
99 full_frame_, power_saver_mode_); 100 full_frame_, throttler_.Pass());
100 if (!success) { 101 if (!success) {
101 instance_->Delete(); 102 instance_->Delete();
102 instance_ = NULL; 103 instance_ = NULL;
103 104
104 blink::WebPlugin* replacement_plugin = 105 blink::WebPlugin* replacement_plugin =
105 GetContentClient()->renderer()->CreatePluginReplacement( 106 GetContentClient()->renderer()->CreatePluginReplacement(
106 init_data_->render_frame, init_data_->module->path()); 107 init_data_->render_frame, init_data_->module->path());
107 if (!replacement_plugin || !replacement_plugin->initialize(container)) 108 if (!replacement_plugin || !replacement_plugin->initialize(container))
108 return false; 109 return false;
109 110
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 283
283 bool PepperWebPluginImpl::canRotateView() { return instance_->CanRotateView(); } 284 bool PepperWebPluginImpl::canRotateView() { return instance_->CanRotateView(); }
284 285
285 void PepperWebPluginImpl::rotateView(RotationType type) { 286 void PepperWebPluginImpl::rotateView(RotationType type) {
286 instance_->RotateView(type); 287 instance_->RotateView(type);
287 } 288 }
288 289
289 bool PepperWebPluginImpl::isPlaceholder() { return false; } 290 bool PepperWebPluginImpl::isPlaceholder() { return false; }
290 291
291 } // namespace content 292 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_webplugin_impl.h ('k') | content/renderer/pepper/plugin_instance_throttler_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698