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

Side by Side Diff: src/shared/ppapi_proxy/browser_globals.cc

Issue 3391010: Update the PPAPI DEPS revision. This change included parameter profile chang... (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 10 years, 3 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 | « src/shared/ppapi_proxy/browser_globals.h ('k') | src/shared/ppapi_proxy/browser_ppp.cc » ('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) 2010 The Native Client Authors. All rights reserved. 1 // Copyright (c) 2010 The Native Client 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 "native_client/src/shared/ppapi_proxy/browser_globals.h" 5 #include "native_client/src/shared/ppapi_proxy/browser_globals.h"
6 #include <map> 6 #include <map>
7 7
8 namespace ppapi_proxy { 8 namespace ppapi_proxy {
9 9
10 // All of these methods are called from the browser main (UI, JavaScript, ...) 10 // All of these methods are called from the browser main (UI, JavaScript, ...)
11 // thread. 11 // thread.
12 12
13 namespace { 13 namespace {
14 14
15 std::map<PP_Instance, BrowserPpp*>* instance_to_ppp_map = NULL; 15 std::map<PP_Instance, BrowserPpp*>* instance_to_ppp_map = NULL;
16 std::map<NaClSrpcChannel*, PP_Module>* channel_to_module_id_map = NULL;
17
16 // The GetInterface pointer from the browser. 18 // The GetInterface pointer from the browser.
17 PPB_GetInterface get_interface; 19 PPB_GetInterface get_interface;
18 // For efficiency, cached results from GetInterface. 20 // For efficiency, cached results from GetInterface.
19 const PPB_Core* core_interface; 21 const PPB_Core* core_interface;
20 const PPB_Var* var_interface; 22 const PPB_Var* var_interface;
21 23
22 } // namespace 24 } // namespace
23 25
24 void SetBrowserPppForInstance(PP_Instance instance, BrowserPpp* browser_ppp) { 26 void SetBrowserPppForInstance(PP_Instance instance, BrowserPpp* browser_ppp) {
25 // If there was no map, create one. 27 // If there was no map, create one.
(...skipping 20 matching lines...) Expand all
46 } 48 }
47 } 49 }
48 50
49 BrowserPpp* LookupBrowserPppForInstance(PP_Instance instance) { 51 BrowserPpp* LookupBrowserPppForInstance(PP_Instance instance) {
50 if (instance_to_ppp_map == NULL) { 52 if (instance_to_ppp_map == NULL) {
51 return NULL; 53 return NULL;
52 } 54 }
53 return (*instance_to_ppp_map)[instance]; 55 return (*instance_to_ppp_map)[instance];
54 } 56 }
55 57
58 void SetModuleIdForSrpcChannel(NaClSrpcChannel* channel, PP_Module module_id) {
59 // If there was no map, create one.
60 if (channel_to_module_id_map == NULL) {
61 channel_to_module_id_map = new std::map<NaClSrpcChannel*, PP_Module>;
62 }
63 // Add the channel to the map.
64 (*channel_to_module_id_map)[channel] = module_id;
65 }
66
67 void UnsetModuleIdForSrpcChannel(NaClSrpcChannel* channel) {
68 if (channel_to_module_id_map == NULL) {
69 // Something major is wrong here. We are deleting a map entry
70 // when there is no map.
71 // TODO(sehr): a CHECK here would be appropriate if we had one in NaCl.
72 return;
73 }
74 // Erase the channel from the map.
75 channel_to_module_id_map->erase(channel);
76 // If there are no more channels alive, remove the map.
77 if (channel_to_module_id_map->size() == 0) {
78 delete channel_to_module_id_map;
79 channel_to_module_id_map = NULL;
80 }
81 }
82
83 PP_Module LookupModuleIdForSrpcChannel(NaClSrpcChannel* channel) {
84 if (channel_to_module_id_map == NULL) {
85 return NULL;
86 }
87 return (*channel_to_module_id_map)[channel];
88 }
89
56 void SetBrowserGetInterface(PPB_GetInterface get_interface_function) { 90 void SetBrowserGetInterface(PPB_GetInterface get_interface_function) {
57 get_interface = get_interface_function; 91 get_interface = get_interface_function;
58 const void* core = (*get_interface_function)(PPB_CORE_INTERFACE); 92 const void* core = (*get_interface_function)(PPB_CORE_INTERFACE);
59 core_interface = reinterpret_cast<const PPB_Core*>(core); 93 core_interface = reinterpret_cast<const PPB_Core*>(core);
60 const void* var = (*get_interface_function)(PPB_VAR_INTERFACE); 94 const void* var = (*get_interface_function)(PPB_VAR_INTERFACE);
61 var_interface = reinterpret_cast<const PPB_Var*>(var); 95 var_interface = reinterpret_cast<const PPB_Var*>(var);
62 } 96 }
63 97
64 const void* GetBrowserInterface(const char* interface_name) { 98 const void* GetBrowserInterface(const char* interface_name) {
65 return (*get_interface)(interface_name); 99 return (*get_interface)(interface_name);
66 } 100 }
67 101
68 const PPB_Core* CoreInterface() { 102 const PPB_Core* CoreInterface() {
69 return core_interface; 103 return core_interface;
70 } 104 }
71 105
72 const PPB_Var* VarInterface() { 106 const PPB_Var* VarInterface() {
73 return var_interface; 107 return var_interface;
74 } 108 }
75 109
76 } // namespace ppapi_proxy 110 } // namespace ppapi_proxy
OLDNEW
« no previous file with comments | « src/shared/ppapi_proxy/browser_globals.h ('k') | src/shared/ppapi_proxy/browser_ppp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698