OLD | NEW |
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/browser_plugin/browser_plugin_manager.h" | 5 #include "content/renderer/browser_plugin/browser_plugin_manager.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "content/common/browser_plugin/browser_plugin_constants.h" | 8 #include "content/common/browser_plugin/browser_plugin_constants.h" |
9 #include "content/common/browser_plugin/browser_plugin_messages.h" | 9 #include "content/common/browser_plugin/browser_plugin_messages.h" |
10 #include "content/common/frame_messages.h" | 10 #include "content/common/frame_messages.h" |
11 #include "content/public/renderer/browser_plugin_delegate.h" | 11 #include "content/public/renderer/browser_plugin_delegate.h" |
12 #include "content/public/renderer/render_thread.h" | 12 #include "content/public/renderer/render_thread.h" |
13 #include "content/renderer/browser_plugin/browser_plugin.h" | 13 #include "content/renderer/browser_plugin/browser_plugin.h" |
14 #include "ipc/ipc_message_macros.h" | 14 #include "ipc/ipc_message_macros.h" |
15 | 15 |
16 namespace content { | 16 namespace content { |
17 | 17 |
18 // static | 18 // static |
19 BrowserPluginManager* BrowserPluginManager::Create( | 19 BrowserPluginManager* BrowserPluginManager::Create( |
20 RenderViewImpl* render_view) { | 20 RenderViewImpl* render_view) { |
21 return new BrowserPluginManager(render_view); | 21 return new BrowserPluginManager(render_view); |
22 } | 22 } |
23 | 23 |
24 BrowserPluginManager::BrowserPluginManager(RenderViewImpl* render_view) | 24 BrowserPluginManager::BrowserPluginManager(RenderViewImpl* render_view) |
25 : RenderViewObserver(render_view), | 25 : RenderViewObserver(render_view), |
26 current_instance_id_(browser_plugin::kInstanceIDNone), | |
27 render_view_(render_view->AsWeakPtr()) { | 26 render_view_(render_view->AsWeakPtr()) { |
28 } | 27 } |
29 | 28 |
30 BrowserPluginManager::~BrowserPluginManager() { | 29 BrowserPluginManager::~BrowserPluginManager() { |
31 } | 30 } |
32 | 31 |
33 void BrowserPluginManager::AddBrowserPlugin( | 32 void BrowserPluginManager::AddBrowserPlugin( |
34 int browser_plugin_instance_id, | 33 int browser_plugin_instance_id, |
35 BrowserPlugin* browser_plugin) { | 34 BrowserPlugin* browser_plugin) { |
36 instances_.AddWithID(browser_plugin, browser_plugin_instance_id); | 35 instances_.AddWithID(browser_plugin, browser_plugin_instance_id); |
37 } | 36 } |
38 | 37 |
39 void BrowserPluginManager::RemoveBrowserPlugin(int browser_plugin_instance_id) { | 38 void BrowserPluginManager::RemoveBrowserPlugin(int browser_plugin_instance_id) { |
40 instances_.Remove(browser_plugin_instance_id); | 39 instances_.Remove(browser_plugin_instance_id); |
41 } | 40 } |
42 | 41 |
43 BrowserPlugin* BrowserPluginManager::GetBrowserPlugin( | 42 BrowserPlugin* BrowserPluginManager::GetBrowserPlugin( |
44 int browser_plugin_instance_id) const { | 43 int browser_plugin_instance_id) const { |
45 return instances_.Lookup(browser_plugin_instance_id); | 44 return instances_.Lookup(browser_plugin_instance_id); |
46 } | 45 } |
47 | 46 |
48 int BrowserPluginManager::GetNextInstanceID() { | 47 int BrowserPluginManager::GetNextInstanceID() { |
49 return ++current_instance_id_; | 48 return RenderThread::Get()->GenerateRoutingID(); |
50 } | 49 } |
51 | 50 |
52 void BrowserPluginManager::UpdateDeviceScaleFactor() { | 51 void BrowserPluginManager::UpdateDeviceScaleFactor() { |
53 IDMap<BrowserPlugin>::iterator iter(&instances_); | 52 IDMap<BrowserPlugin>::iterator iter(&instances_); |
54 while (!iter.IsAtEnd()) { | 53 while (!iter.IsAtEnd()) { |
55 iter.GetCurrentValue()->UpdateDeviceScaleFactor(); | 54 iter.GetCurrentValue()->UpdateDeviceScaleFactor(); |
56 iter.Advance(); | 55 iter.Advance(); |
57 } | 56 } |
58 } | 57 } |
59 | 58 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 122 |
124 FrameHostMsg_CompositorFrameSwappedACK_Params params; | 123 FrameHostMsg_CompositorFrameSwappedACK_Params params; |
125 params.producing_host_id = param.b.producing_host_id; | 124 params.producing_host_id = param.b.producing_host_id; |
126 params.producing_route_id = param.b.producing_route_id; | 125 params.producing_route_id = param.b.producing_route_id; |
127 params.output_surface_id = param.b.output_surface_id; | 126 params.output_surface_id = param.b.output_surface_id; |
128 Send(new BrowserPluginHostMsg_CompositorFrameSwappedACK( | 127 Send(new BrowserPluginHostMsg_CompositorFrameSwappedACK( |
129 routing_id(), param.a, params)); | 128 routing_id(), param.a, params)); |
130 } | 129 } |
131 | 130 |
132 } // namespace content | 131 } // namespace content |
OLD | NEW |