Index: ppapi/proxy/browser_dispatcher.cc |
=================================================================== |
--- ppapi/proxy/browser_dispatcher.cc (revision 0) |
+++ ppapi/proxy/browser_dispatcher.cc (revision 0) |
@@ -0,0 +1,63 @@ |
+// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "ppapi/proxy/browser_dispatcher.h" |
+ |
+#include <map> |
+ |
+#include "base/logging.h" |
+#include "ppapi/proxy/browser_var_serialization.h" |
+ |
+namespace pp { |
+namespace proxy { |
+ |
+namespace { |
+ |
+typedef std::map<PP_Instance, BrowserDispatcher*> InstanceToDispatcherMap; |
+InstanceToDispatcherMap* g_instance_to_dispatcher = NULL; |
+ |
+} // namespace |
+ |
+BrowserDispatcher::BrowserDispatcher(const PPB_Var_Deprecated* var_interface, |
+ PP_Module module, |
+ GetInterfaceFunc local_get_interface) |
+ : Dispatcher(local_get_interface) { |
+ SetSerialization(new BrowserVarSerialization(var_interface, module)); |
+} |
+ |
+BrowserDispatcher::~BrowserDispatcher() { |
+} |
+ |
+// static |
+BrowserDispatcher* BrowserDispatcher::GetForInstance(PP_Instance instance) { |
+ if (!g_instance_to_dispatcher) |
+ return NULL; |
+ InstanceToDispatcherMap::iterator found = g_instance_to_dispatcher->find( |
+ instance); |
+ if (found == g_instance_to_dispatcher->end()) |
+ return NULL; |
+ return found->second; |
+} |
+ |
+// static |
+void BrowserDispatcher::SetForInstance(PP_Instance instance, |
+ BrowserDispatcher* dispatcher) { |
+ if (!g_instance_to_dispatcher) |
+ g_instance_to_dispatcher = new InstanceToDispatcherMap; |
+ (*g_instance_to_dispatcher)[instance] = dispatcher; |
+} |
+ |
+// static |
+void BrowserDispatcher::RemoveForInstance(PP_Instance instance) { |
+ if (!g_instance_to_dispatcher) |
+ return; |
+ InstanceToDispatcherMap::iterator found = g_instance_to_dispatcher->find( |
+ instance); |
+ if (found != g_instance_to_dispatcher->end()) |
+ g_instance_to_dispatcher->erase(found); |
+} |
+ |
+} // namespace proxy |
+} // namespace pp |
+ |
Property changes on: ppapi/proxy/browser_dispatcher.cc |
___________________________________________________________________ |
Added: svn:eol-style |
+ LF |