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

Side by Side Diff: ppapi/cpp/instance.cc

Issue 9481015: Make the PPP wrappers take an Instance*. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: USELESS PATCH DESCRIPTION Created 8 years, 9 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 | « ppapi/cpp/instance.h ('k') | ppapi/cpp/mouse_lock.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 "ppapi/cpp/instance.h" 5 #include "ppapi/cpp/instance.h"
6 6
7 #include "ppapi/c/pp_errors.h" 7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/c/ppb_input_event.h" 8 #include "ppapi/c/ppb_input_event.h"
9 #include "ppapi/c/ppb_instance.h" 9 #include "ppapi/c/ppb_instance.h"
10 #include "ppapi/c/ppb_messaging.h" 10 #include "ppapi/c/ppb_messaging.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 131
132 void Instance::AddPerInstanceObject(const std::string& interface_name, 132 void Instance::AddPerInstanceObject(const std::string& interface_name,
133 void* object) { 133 void* object) {
134 // Ensure we're not trying to register more than one object per interface 134 // Ensure we're not trying to register more than one object per interface
135 // type. Otherwise, we'll get confused in GetPerInstanceObject. 135 // type. Otherwise, we'll get confused in GetPerInstanceObject.
136 PP_DCHECK(interface_name_to_objects_.find(interface_name) == 136 PP_DCHECK(interface_name_to_objects_.find(interface_name) ==
137 interface_name_to_objects_.end()); 137 interface_name_to_objects_.end());
138 interface_name_to_objects_[interface_name] = object; 138 interface_name_to_objects_[interface_name] = object;
139 } 139 }
140 140
141 // static
142 void Instance::AddPerInstanceObject(const InstanceHandle& instance,
143 const std::string& interface_name,
144 void* object) {
145 // TODO(brettw) assert we're on the main thread (instance is not threadsafe
146 // and may be deleted from the main thread).
147 Instance* that = Module::Get()->InstanceForPPInstance(instance.pp_instance());
148 if (!that)
149 return;
150 that->AddPerInstanceObject(interface_name, object);
151 }
152
153 void Instance::RemovePerInstanceObject(const std::string& interface_name, 141 void Instance::RemovePerInstanceObject(const std::string& interface_name,
154 void* object) { 142 void* object) {
155 InterfaceNameToObjectMap::iterator found = interface_name_to_objects_.find( 143 InterfaceNameToObjectMap::iterator found = interface_name_to_objects_.find(
156 interface_name); 144 interface_name);
157 if (found == interface_name_to_objects_.end()) { 145 if (found == interface_name_to_objects_.end()) {
158 // Attempting to unregister an object that doesn't exist or was already 146 // Attempting to unregister an object that doesn't exist or was already
159 // unregistered. 147 // unregistered.
160 PP_DCHECK(false); 148 PP_DCHECK(false);
161 return; 149 return;
162 } 150 }
(...skipping 23 matching lines...) Expand all
186 if (!that) 174 if (!that)
187 return NULL; 175 return NULL;
188 InterfaceNameToObjectMap::iterator found = 176 InterfaceNameToObjectMap::iterator found =
189 that->interface_name_to_objects_.find(interface_name); 177 that->interface_name_to_objects_.find(interface_name);
190 if (found == that->interface_name_to_objects_.end()) 178 if (found == that->interface_name_to_objects_.end())
191 return NULL; 179 return NULL;
192 return found->second; 180 return found->second;
193 } 181 }
194 182
195 } // namespace pp 183 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/cpp/instance.h ('k') | ppapi/cpp/mouse_lock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698