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

Side by Side Diff: chrome/plugin/webplugin_proxy.cc

Issue 5682008: Make members of Singleton<T> private and only visible to the singleton type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 10 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/plugin/webplugin_proxy.h" 5 #include "chrome/plugin/webplugin_proxy.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include "app/win_util.h" 10 #include "app/win_util.h"
11 #endif 11 #endif
12 #include "base/lazy_instance.h"
12 #if defined(OS_MACOSX) 13 #if defined(OS_MACOSX)
13 #include "base/mac_util.h" 14 #include "base/mac_util.h"
14 #include "base/mac/scoped_cftyperef.h" 15 #include "base/mac/scoped_cftyperef.h"
15 #endif 16 #endif
16 #include "base/scoped_handle.h" 17 #include "base/scoped_handle.h"
17 #include "base/shared_memory.h" 18 #include "base/shared_memory.h"
18 #include "base/singleton.h"
19 #include "build/build_config.h" 19 #include "build/build_config.h"
20 #include "chrome/common/child_process_logging.h" 20 #include "chrome/common/child_process_logging.h"
21 #include "chrome/common/plugin_messages.h" 21 #include "chrome/common/plugin_messages.h"
22 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
23 #include "chrome/plugin/npobject_proxy.h" 23 #include "chrome/plugin/npobject_proxy.h"
24 #include "chrome/plugin/npobject_util.h" 24 #include "chrome/plugin/npobject_util.h"
25 #include "chrome/plugin/plugin_channel.h" 25 #include "chrome/plugin/plugin_channel.h"
26 #include "chrome/plugin/plugin_thread.h" 26 #include "chrome/plugin/plugin_thread.h"
27 #if defined(OS_MACOSX) 27 #if defined(OS_MACOSX)
28 #include "chrome/plugin/webplugin_accelerated_surface_proxy_mac.h" 28 #include "chrome/plugin/webplugin_accelerated_surface_proxy_mac.h"
(...skipping 11 matching lines...) Expand all
40 #include "app/x11_util_internal.h" 40 #include "app/x11_util_internal.h"
41 #endif 41 #endif
42 42
43 using WebKit::WebBindings; 43 using WebKit::WebBindings;
44 using webkit_glue::WebPluginResourceClient; 44 using webkit_glue::WebPluginResourceClient;
45 #if defined(OS_MACOSX) 45 #if defined(OS_MACOSX)
46 using webkit_glue::WebPluginAcceleratedSurface; 46 using webkit_glue::WebPluginAcceleratedSurface;
47 #endif 47 #endif
48 48
49 typedef std::map<CPBrowsingContext, WebPluginProxy*> ContextMap; 49 typedef std::map<CPBrowsingContext, WebPluginProxy*> ContextMap;
50 static ContextMap& GetContextMap() { 50 static base::LazyInstance<ContextMap> g_context_map(base::LINKER_INITIALIZED);
51 return *Singleton<ContextMap>::get();
52 }
53 51
54 WebPluginProxy::WebPluginProxy( 52 WebPluginProxy::WebPluginProxy(
55 PluginChannel* channel, 53 PluginChannel* channel,
56 int route_id, 54 int route_id,
57 const GURL& page_url, 55 const GURL& page_url,
58 gfx::NativeViewId containing_window, 56 gfx::NativeViewId containing_window,
59 int host_render_view_routing_id) 57 int host_render_view_routing_id)
60 : channel_(channel), 58 : channel_(channel),
61 route_id_(route_id), 59 route_id_(route_id),
62 cp_browsing_context_(0), 60 cp_browsing_context_(0),
(...skipping 23 matching lines...) Expand all
86 if (vis->red_mask == 0xff0000 && 84 if (vis->red_mask == 0xff0000 &&
87 vis->green_mask == 0xff00 && 85 vis->green_mask == 0xff00 &&
88 vis->blue_mask == 0xff) 86 vis->blue_mask == 0xff)
89 use_shm_pixmap_ = true; 87 use_shm_pixmap_ = true;
90 } 88 }
91 #endif 89 #endif
92 } 90 }
93 91
94 WebPluginProxy::~WebPluginProxy() { 92 WebPluginProxy::~WebPluginProxy() {
95 if (cp_browsing_context_) 93 if (cp_browsing_context_)
96 GetContextMap().erase(cp_browsing_context_); 94 g_context_map.Get().erase(cp_browsing_context_);
97 95
98 #if defined(USE_X11) 96 #if defined(USE_X11)
99 if (windowless_shm_pixmap_ != None) 97 if (windowless_shm_pixmap_ != None)
100 XFreePixmap(x11_util::GetXDisplay(), windowless_shm_pixmap_); 98 XFreePixmap(x11_util::GetXDisplay(), windowless_shm_pixmap_);
101 #endif 99 #endif
102 100
103 #if defined(OS_MACOSX) 101 #if defined(OS_MACOSX)
104 // Destroy the surface early, since it may send messages during cleanup. 102 // Destroy the surface early, since it may send messages during cleanup.
105 if (accelerated_surface_.get()) 103 if (accelerated_surface_.get())
106 accelerated_surface_.reset(); 104 accelerated_surface_.reset();
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 } 262 }
265 263
266 void WebPluginProxy::OnMissingPluginStatus(int status) { 264 void WebPluginProxy::OnMissingPluginStatus(int status) {
267 Send(new PluginHostMsg_MissingPluginStatus(route_id_, status)); 265 Send(new PluginHostMsg_MissingPluginStatus(route_id_, status));
268 } 266 }
269 267
270 CPBrowsingContext WebPluginProxy::GetCPBrowsingContext() { 268 CPBrowsingContext WebPluginProxy::GetCPBrowsingContext() {
271 if (cp_browsing_context_ == 0) { 269 if (cp_browsing_context_ == 0) {
272 Send(new PluginHostMsg_GetCPBrowsingContext(route_id_, 270 Send(new PluginHostMsg_GetCPBrowsingContext(route_id_,
273 &cp_browsing_context_)); 271 &cp_browsing_context_));
274 GetContextMap()[cp_browsing_context_] = this; 272 g_context_map.Get()[cp_browsing_context_] = this;
275 } 273 }
276 return cp_browsing_context_; 274 return cp_browsing_context_;
277 } 275 }
278 276
279 WebPluginProxy* WebPluginProxy::FromCPBrowsingContext( 277 WebPluginProxy* WebPluginProxy::FromCPBrowsingContext(
280 CPBrowsingContext context) { 278 CPBrowsingContext context) {
281 return GetContextMap()[context]; 279 return g_context_map.Get()[context];
282 } 280 }
283 281
284 WebPluginResourceClient* WebPluginProxy::GetResourceClient(int id) { 282 WebPluginResourceClient* WebPluginProxy::GetResourceClient(int id) {
285 ResourceClientMap::iterator iterator = resource_clients_.find(id); 283 ResourceClientMap::iterator iterator = resource_clients_.find(id);
286 // The IPC messages which deal with streams are now asynchronous. It is 284 // The IPC messages which deal with streams are now asynchronous. It is
287 // now possible to receive stream messages from the renderer for streams 285 // now possible to receive stream messages from the renderer for streams
288 // which may have been cancelled by the plugin. 286 // which may have been cancelled by the plugin.
289 if (iterator == resource_clients_.end()) { 287 if (iterator == resource_clients_.end()) {
290 return NULL; 288 return NULL;
291 } 289 }
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 } else { 727 } else {
730 index++; 728 index++;
731 } 729 }
732 } 730 }
733 } 731 }
734 732
735 void WebPluginProxy::URLRedirectResponse(bool allow, int resource_id) { 733 void WebPluginProxy::URLRedirectResponse(bool allow, int resource_id) {
736 Send(new PluginHostMsg_URLRedirectResponse(route_id_, allow, resource_id)); 734 Send(new PluginHostMsg_URLRedirectResponse(route_id_, allow, resource_id));
737 } 735 }
738 736
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698