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

Side by Side Diff: src/trusted/plugin/browser_interface.cc

Issue 7799028: Remove src/trusted/plugin (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: fix gyp file for necessary -I Created 9 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/trusted/plugin/browser_interface.h ('k') | src/trusted/plugin/browser_utils.cc » ('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 Native Client 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 <assert.h>
6
7 #include "native_client/src/trusted/plugin/browser_interface.h"
8
9 #include "native_client/src/include/checked_cast.h"
10 #include "native_client/src/include/elf.h"
11 #include "native_client/src/include/nacl_macros.h"
12 #include "native_client/src/include/portability.h"
13 #include "native_client/src/trusted/plugin/scriptable_handle.h"
14
15 #include "ppapi/c/dev/ppb_console_dev.h"
16 #include "ppapi/c/ppb_var.h"
17 #include "ppapi/cpp/module.h"
18 #include "ppapi/cpp/private/instance_private.h"
19 #include "ppapi/cpp/private/var_private.h"
20
21 using nacl::assert_cast;
22
23 namespace plugin {
24
25 uintptr_t BrowserInterface::StringToIdentifier(const nacl::string& str) {
26 StringToIdentifierMap::iterator iter = string_to_identifier_map_.find(str);
27 if (iter == string_to_identifier_map_.end()) {
28 uintptr_t id = next_identifier++;
29 string_to_identifier_map_.insert(make_pair(str, id));
30 identifier_to_string_map_.insert(make_pair(id, str));
31 return id;
32 }
33 return string_to_identifier_map_[str];
34 }
35
36
37 nacl::string BrowserInterface::IdentifierToString(uintptr_t ident) {
38 assert(identifier_to_string_map_.find(ident) !=
39 identifier_to_string_map_.end());
40 return identifier_to_string_map_[ident];
41 }
42
43
44 void BrowserInterface::AddToConsole(pp::InstancePrivate* instance,
45 const nacl::string& text) {
46 pp::Module* module = pp::Module::Get();
47 const PPB_Var* var_interface =
48 static_cast<const struct PPB_Var*>(
49 module->GetBrowserInterface(PPB_VAR_INTERFACE));
50 nacl::string prefix_string("NativeClient");
51 PP_Var prefix =
52 var_interface->VarFromUtf8(module->pp_module(),
53 prefix_string.c_str(),
54 static_cast<uint32_t>(prefix_string.size()));
55 PP_Var str = var_interface->VarFromUtf8(module->pp_module(),
56 text.c_str(),
57 static_cast<uint32_t>(text.size()));
58 const PPB_Console_Dev* console_interface =
59 static_cast<const struct PPB_Console_Dev*>(
60 module->GetBrowserInterface(PPB_CONSOLE_DEV_INTERFACE));
61 console_interface->LogWithSource(instance->pp_instance(),
62 PP_LOGLEVEL_LOG,
63 prefix,
64 str);
65 var_interface->Release(prefix);
66 var_interface->Release(str);
67 }
68
69 } // namespace plugin
OLDNEW
« no previous file with comments | « src/trusted/plugin/browser_interface.h ('k') | src/trusted/plugin/browser_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698