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

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

Issue 9390028: Remove browser support for non-PPAPI nexes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 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
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 <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 PPB_Var*>(
49 module->GetBrowserInterface(PPB_VAR_INTERFACE));
50 nacl::string prefix_string("NativeClient");
51 PP_Var prefix =
52 var_interface->VarFromUtf8(prefix_string.c_str(),
53 static_cast<uint32_t>(prefix_string.size()));
54 PP_Var str = var_interface->VarFromUtf8(text.c_str(),
55 static_cast<uint32_t>(text.size()));
56 const PPB_Console_Dev* console_interface =
57 static_cast<const PPB_Console_Dev*>(
58 module->GetBrowserInterface(PPB_CONSOLE_DEV_INTERFACE));
59 console_interface->LogWithSource(instance->pp_instance(),
60 PP_LOGLEVEL_LOG,
61 prefix,
62 str);
63 var_interface->Release(prefix);
64 var_interface->Release(str);
65 }
66
67 } // namespace plugin
OLDNEW
« no previous file with comments | « ppapi/native_client/src/trusted/plugin/browser_interface.h ('k') | ppapi/native_client/src/trusted/plugin/build.scons » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698