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

Side by Side Diff: gpu/np_utils/np_browser_stub.cc

Issue 481007: Deleted np_utils library. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years 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 | « gpu/np_utils/np_browser_stub.h ('k') | gpu/np_utils/np_class.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) 2006-2008 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 "gpu/np_utils/np_browser_stub.h"
6 #include "base/logging.h"
7 #include "base/message_loop.h"
8
9 namespace np_utils {
10
11 StubNPBrowser::StubNPBrowser() : NPBrowser(NULL) {
12 }
13
14 StubNPBrowser::~StubNPBrowser() {
15 }
16
17 NPIdentifier StubNPBrowser::GetStringIdentifier(const NPUTF8* name) {
18 static std::set<std::string> names;
19 std::set<std::string>::iterator it = names.find(name);
20 if (it == names.end()) {
21 it = names.insert(name).first;
22 }
23 return const_cast<NPUTF8*>((*it).c_str());
24 }
25
26 void* StubNPBrowser::MemAlloc(size_t size) {
27 return malloc(size);
28 }
29
30 void StubNPBrowser::MemFree(void* p) {
31 free(p);
32 }
33
34 NPObject* StubNPBrowser::CreateObject(NPP npp, const NPClass* cl) {
35 NPObject* object = cl->allocate(npp, const_cast<NPClass*>(cl));
36 object->referenceCount = 1;
37 object->_class = const_cast<NPClass*>(cl);
38 return object;
39 }
40
41 NPObject* StubNPBrowser::RetainObject(NPObject* object) {
42 ++object->referenceCount;
43 return object;
44 }
45
46 void StubNPBrowser::ReleaseObject(NPObject* object) {
47 DCHECK_GE(object->referenceCount, 0u);
48 --object->referenceCount;
49 if (object->referenceCount == 0) {
50 object->_class->deallocate(object);
51 }
52 }
53
54 void StubNPBrowser::ReleaseVariantValue(NPVariant* variant) {
55 if (NPVARIANT_IS_STRING(*variant)) {
56 MemFree(const_cast<NPUTF8*>(variant->value.stringValue.UTF8Characters));
57 } else if (NPVARIANT_IS_OBJECT(*variant)) {
58 ReleaseObject(NPVARIANT_TO_OBJECT(*variant));
59 }
60 }
61
62 bool StubNPBrowser::HasProperty(NPP npp,
63 NPObject* object,
64 NPIdentifier name) {
65 return object->_class->hasProperty(object, name);
66 }
67
68 bool StubNPBrowser::GetProperty(NPP npp,
69 NPObject* object,
70 NPIdentifier name,
71 NPVariant* result) {
72 return object->_class->getProperty(object, name, result);
73 }
74
75 bool StubNPBrowser::SetProperty(NPP npp,
76 NPObject* object,
77 NPIdentifier name,
78 const NPVariant* result) {
79 return object->_class->setProperty(object, name, result);
80 }
81
82 bool StubNPBrowser::RemoveProperty(NPP npp,
83 NPObject* object,
84 NPIdentifier name) {
85 return object->_class->removeProperty(object, name);
86 }
87
88 bool StubNPBrowser::HasMethod(NPP npp,
89 NPObject* object,
90 NPIdentifier name) {
91 return object->_class->hasMethod(object, name);
92 }
93
94 bool StubNPBrowser::Invoke(NPP npp,
95 NPObject* object,
96 NPIdentifier name,
97 const NPVariant* args,
98 uint32_t num_args,
99 NPVariant* result) {
100 return object->_class->invoke(object, name, args, num_args, result);
101 }
102
103 NPObject* StubNPBrowser::GetWindowNPObject(NPP npp) {
104 return NULL;
105 }
106
107 void StubNPBrowser::PluginThreadAsyncCall(
108 NPP npp,
109 PluginThreadAsyncCallProc callback,
110 void* data) {
111 MessageLoop::current()->PostTask(FROM_HERE,
112 NewRunnableFunction(callback, data));
113 }
114
115 uint32 StubNPBrowser::ScheduleTimer(NPP npp,
116 uint32 interval,
117 bool repeat,
118 TimerProc callback) {
119 return 0;
120 }
121
122 void StubNPBrowser::UnscheduleTimer(NPP npp, uint32 timer_id) {
123 }
124
125 } // namespace np_utils
OLDNEW
« no previous file with comments | « gpu/np_utils/np_browser_stub.h ('k') | gpu/np_utils/np_class.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698