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

Side by Side Diff: ppapi/proxy/ppb_var_proxy.cc

Issue 6995083: Proxy PPB_Var, fix o-o-p string var id tracking. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated copyright header Created 9 years, 6 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/proxy/ppb_var_proxy.h ('k') | ppapi/tests/test_var.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ppapi/proxy/ppb_var_proxy.h"
6
7 #include "ppapi/c/pp_var.h"
8 #include "ppapi/c/ppb_var.h"
9 #include "ppapi/proxy/plugin_var_tracker.h"
10
11 namespace pp {
12 namespace proxy {
13
14 namespace {
15
16 // PPP_Var plugin --------------------------------------------------------------
17
18 void AddRefVar(PP_Var var) {
19 PluginVarTracker::GetInstance()->AddRef(var);
20 }
21
22 void ReleaseVar(PP_Var var) {
23 PluginVarTracker::GetInstance()->Release(var);
24 }
25
26 PP_Var VarFromUtf8(PP_Module module, const char* data, uint32_t len) {
27 PP_Var ret = {};
28 ret.type = PP_VARTYPE_STRING;
29 ret.value.as_id = PluginVarTracker::GetInstance()->MakeString(data, len);
30 return ret;
31 }
32
33 const char* VarToUtf8(PP_Var var, uint32_t* len) {
34 const std::string* str =
35 PluginVarTracker::GetInstance()->GetExistingString(var);
36 if (str) {
37 *len = static_cast<uint32_t>(str->size());
38 return str->c_str();
39 }
40 *len = 0;
41 return NULL;
42 }
43
44 const PPB_Var var_interface = {
45 &AddRefVar,
46 &ReleaseVar,
47 &VarFromUtf8,
48 &VarToUtf8
49 };
50
51 InterfaceProxy* CreateVarProxy(Dispatcher* dispatcher,
52 const void* target_interface) {
53 return new PPB_Var_Proxy(dispatcher, target_interface);
54 }
55
56 } // namespace
57
58 PPB_Var_Proxy::PPB_Var_Proxy(Dispatcher* dispatcher,
59 const void* target_interface)
60 : InterfaceProxy(dispatcher, target_interface) {
61 }
62
63 PPB_Var_Proxy::~PPB_Var_Proxy() {
64 }
65
66 // static
67 const InterfaceProxy::Info* PPB_Var_Proxy::GetInfo() {
68 static const Info info = {
69 &var_interface,
70 PPB_VAR_INTERFACE,
71 INTERFACE_ID_PPB_VAR,
72 false,
73 &CreateVarProxy,
74 };
75 return &info;
76 }
77
78 bool PPB_Var_Proxy::OnMessageReceived(const IPC::Message& msg) {
79 // All PPB_Var calls are handled locally; there is no need to send or receive
80 // messages here.
81 return false;
82 }
83
84 } // namespace proxy
85 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_var_proxy.h ('k') | ppapi/tests/test_var.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698