Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / chrome / renderer / plugins / plugin_preroller.h
blobb059d77f040e78af516282d754cf9893df405c3a
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 CHROME_RENDERER_PLUGINS_PLUGIN_PREROLLER_H_
6 #define CHROME_RENDERER_PLUGINS_PLUGIN_PREROLLER_H_
8 #include "base/macros.h"
9 #include "content/public/common/webplugininfo.h"
10 #include "content/public/renderer/plugin_instance_throttler.h"
11 #include "content/public/renderer/render_frame_observer.h"
12 #include "third_party/WebKit/public/web/WebPluginParams.h"
13 #include "url/gurl.h"
15 namespace blink {
16 class WebLocalFrame;
17 class WebPlugin;
20 class SkBitmap;
22 // This class manages a plugin briefly for the purposes of keyframe extraction.
23 // Once a keyframe has been extracted, this class will replace the plugin with
24 // a ChromePluginPlaceholder. The actual plugin will continue to live in a
25 // throttled state. This class manages its own lifetime.
26 class PluginPreroller : public content::PluginInstanceThrottler::Observer,
27 public content::RenderFrameObserver {
28 public:
29 // Does not take ownership of either |plugin| or |throttler|.
30 PluginPreroller(content::RenderFrame* render_frame,
31 blink::WebLocalFrame* frame,
32 const blink::WebPluginParams& params,
33 const content::WebPluginInfo& info,
34 const std::string& identifier,
35 const base::string16& name,
36 const base::string16& message,
37 content::PluginInstanceThrottler* throttler);
39 ~PluginPreroller() override;
41 private:
42 // content::PluginInstanceThrottler::Observer methods:
43 void OnKeyframeExtracted(const SkBitmap* bitmap) override;
44 void OnThrottleStateChange() override;
45 void OnThrottlerDestroyed() override;
47 blink::WebLocalFrame* frame_;
48 blink::WebPluginParams params_;
49 content::WebPluginInfo info_;
50 std::string identifier_;
51 base::string16 name_;
52 base::string16 message_;
54 content::PluginInstanceThrottler* throttler_;
56 GURL keyframe_data_url_;
58 DISALLOW_COPY_AND_ASSIGN(PluginPreroller);
61 #endif // CHROME_RENDERER_PLUGINS_PLUGIN_PREROLLER_H_