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

Side by Side Diff: webkit/plugins/ppapi/host_globals.cc

Issue 8333004: Rename InterfaceID to ApiID and move the file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged Created 9 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « webkit/plugins/ppapi/host_globals.h ('k') | webkit/plugins/ppapi/host_var_tracker.h » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/plugins/ppapi/host_globals.h" 5 #include "webkit/plugins/ppapi/host_globals.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
11 #include "ppapi/proxy/interface_id.h" 11 #include "ppapi/shared_impl/api_id.h"
12 #include "ppapi/shared_impl/function_group_base.h" 12 #include "ppapi/shared_impl/function_group_base.h"
13 #include "ppapi/shared_impl/id_assignment.h" 13 #include "ppapi/shared_impl/id_assignment.h"
14 #include "webkit/plugins/ppapi/plugin_module.h" 14 #include "webkit/plugins/ppapi/plugin_module.h"
15 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 15 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
16 #include "webkit/plugins/ppapi/ppb_cursor_control_impl.h" 16 #include "webkit/plugins/ppapi/ppb_cursor_control_impl.h"
17 #include "webkit/plugins/ppapi/ppb_font_impl.h" 17 #include "webkit/plugins/ppapi/ppb_font_impl.h"
18 #include "webkit/plugins/ppapi/ppb_text_input_impl.h" 18 #include "webkit/plugins/ppapi/ppb_text_input_impl.h"
19 #include "webkit/plugins/ppapi/resource_creation_impl.h" 19 #include "webkit/plugins/ppapi/resource_creation_impl.h"
20 20
21 using ppapi::CheckIdType; 21 using ppapi::CheckIdType;
22 using ppapi::MakeTypedId; 22 using ppapi::MakeTypedId;
23 using ppapi::PPIdType; 23 using ppapi::PPIdType;
24 24
25 namespace webkit { 25 namespace webkit {
26 namespace ppapi { 26 namespace ppapi {
27 27
28 struct HostGlobals::InstanceData { 28 struct HostGlobals::InstanceData {
29 InstanceData() : instance(0) {} 29 InstanceData() : instance(0) {}
30 30
31 // Non-owning pointer to the instance object. When a PluginInstance is 31 // Non-owning pointer to the instance object. When a PluginInstance is
32 // destroyed, it will notify us and we'll delete all associated data. 32 // destroyed, it will notify us and we'll delete all associated data.
33 PluginInstance* instance; 33 PluginInstance* instance;
34 34
35 // Lazily allocated function proxies for the different interfaces. 35 // Lazily allocated function proxies for the different interfaces.
36 scoped_ptr< ::ppapi::FunctionGroupBase > 36 scoped_ptr< ::ppapi::FunctionGroupBase >
37 function_proxies[::ppapi::proxy::INTERFACE_ID_COUNT]; 37 function_proxies[::ppapi::API_ID_COUNT];
38 }; 38 };
39 39
40 HostGlobals* HostGlobals::host_globals_ = NULL; 40 HostGlobals* HostGlobals::host_globals_ = NULL;
41 41
42 HostGlobals::HostGlobals() : ::ppapi::PpapiGlobals() { 42 HostGlobals::HostGlobals() : ::ppapi::PpapiGlobals() {
43 DCHECK(!host_globals_); 43 DCHECK(!host_globals_);
44 host_globals_ = this; 44 host_globals_ = this;
45 } 45 }
46 46
47 HostGlobals::~HostGlobals() { 47 HostGlobals::~HostGlobals() {
48 DCHECK(host_globals_ == this); 48 DCHECK(host_globals_ == this);
49 host_globals_ = NULL; 49 host_globals_ = NULL;
50 } 50 }
51 51
52 ::ppapi::ResourceTracker* HostGlobals::GetResourceTracker() { 52 ::ppapi::ResourceTracker* HostGlobals::GetResourceTracker() {
53 return &host_resource_tracker_; 53 return &host_resource_tracker_;
54 } 54 }
55 55
56 ::ppapi::VarTracker* HostGlobals::GetVarTracker() { 56 ::ppapi::VarTracker* HostGlobals::GetVarTracker() {
57 return &host_var_tracker_; 57 return &host_var_tracker_;
58 } 58 }
59 59
60 ::ppapi::FunctionGroupBase* HostGlobals::GetFunctionAPI( 60 ::ppapi::FunctionGroupBase* HostGlobals::GetFunctionAPI(PP_Instance pp_instance,
61 PP_Instance pp_instance, 61 ::ppapi::ApiID id) {
62 ::ppapi::proxy::InterfaceID id) {
63 // Get the instance object. This also ensures that the instance data is in 62 // Get the instance object. This also ensures that the instance data is in
64 // the map, since we need it below. 63 // the map, since we need it below.
65 PluginInstance* instance = GetInstance(pp_instance); 64 PluginInstance* instance = GetInstance(pp_instance);
66 if (!instance) 65 if (!instance)
67 return NULL; 66 return NULL;
68 67
69 // The instance one is special, since it's just implemented by the instance 68 // The instance one is special, since it's just implemented by the instance
70 // object. 69 // object.
71 if (id == ::ppapi::proxy::INTERFACE_ID_PPB_INSTANCE) 70 if (id == ::ppapi::API_ID_PPB_INSTANCE)
72 return instance; 71 return instance;
73 72
74 scoped_ptr< ::ppapi::FunctionGroupBase >& proxy = 73 scoped_ptr< ::ppapi::FunctionGroupBase >& proxy =
75 instance_map_[pp_instance]->function_proxies[id]; 74 instance_map_[pp_instance]->function_proxies[id];
76 if (proxy.get()) 75 if (proxy.get())
77 return proxy.get(); 76 return proxy.get();
78 77
79 switch (id) { 78 switch (id) {
80 case ::ppapi::proxy::INTERFACE_ID_PPB_CURSORCONTROL: 79 case ::ppapi::API_ID_PPB_CURSORCONTROL:
81 proxy.reset(new PPB_CursorControl_Impl(instance)); 80 proxy.reset(new PPB_CursorControl_Impl(instance));
82 break; 81 break;
83 case ::ppapi::proxy::INTERFACE_ID_PPB_FONT: 82 case ::ppapi::API_ID_PPB_FONT:
84 proxy.reset(new PPB_Font_FunctionImpl(instance)); 83 proxy.reset(new PPB_Font_FunctionImpl(instance));
85 break; 84 break;
86 case ::ppapi::proxy::INTERFACE_ID_PPB_TEXT_INPUT: 85 case ::ppapi::API_ID_PPB_TEXT_INPUT:
87 proxy.reset(new PPB_TextInput_Impl(instance)); 86 proxy.reset(new PPB_TextInput_Impl(instance));
88 break; 87 break;
89 case ::ppapi::proxy::INTERFACE_ID_RESOURCE_CREATION: 88 case ::ppapi::API_ID_RESOURCE_CREATION:
90 proxy.reset(new ResourceCreationImpl(instance)); 89 proxy.reset(new ResourceCreationImpl(instance));
91 break; 90 break;
92 default: 91 default:
93 NOTREACHED(); 92 NOTREACHED();
94 } 93 }
95 94
96 return proxy.get(); 95 return proxy.get();
97 } 96 }
98 97
99 PP_Module HostGlobals::GetModuleForInstance(PP_Instance instance) { 98 PP_Module HostGlobals::GetModuleForInstance(PP_Instance instance) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 DLOG_IF(ERROR, !CheckIdType(instance, ::ppapi::PP_ID_TYPE_INSTANCE)) 178 DLOG_IF(ERROR, !CheckIdType(instance, ::ppapi::PP_ID_TYPE_INSTANCE))
180 << instance << " is not a PP_Instance."; 179 << instance << " is not a PP_Instance.";
181 InstanceMap::iterator found = instance_map_.find(instance); 180 InstanceMap::iterator found = instance_map_.find(instance);
182 if (found == instance_map_.end()) 181 if (found == instance_map_.end())
183 return NULL; 182 return NULL;
184 return found->second->instance; 183 return found->second->instance;
185 } 184 }
186 185
187 } // namespace ppapi 186 } // namespace ppapi
188 } // namespace webkit 187 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/host_globals.h ('k') | webkit/plugins/ppapi/host_var_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698