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

Side by Side Diff: plugins/update/npapi/testing/stubs.cc

Issue 624713003: Keep only base/extractor.[cc|h]. (Closed) Base URL: https://chromium.googlesource.com/external/omaha.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « plugins/update/npapi/testing/stubs.h ('k') | plugins/update/npapi/urlpropbag.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 2009 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 // ========================================================================
15
16 #include "omaha/plugins/update/npapi/testing/stubs.h"
17 #include <malloc.h>
18 #include <string.h>
19 #include "base/debug.h"
20
21 namespace omaha {
22
23 NPIdentifierFactory::NPIdentifierFactory() {
24 }
25
26 NPIdentifierFactory::~NPIdentifierFactory() {
27 for (std::vector<NPIdentifier>::const_iterator it = identifiers_.begin();
28 it != identifiers_.end(); ++it) {
29 free(*it);
30 }
31 }
32
33 NPIdentifier NPIdentifierFactory::Create(const char* name) {
34 NPIdentifier identifier = _strdup(name);
35 identifiers_.push_back(identifier);
36 return identifier;
37 }
38
39 } // namespace omaha
40
41 extern "C" {
42 void* NPN_MemAlloc(uint32 size) {
43 return malloc(size);
44 }
45
46 void NPN_MemFree(void* ptr) {
47 free(ptr);
48 }
49
50 NPUTF8* NPN_UTF8FromIdentifier(NPIdentifier identifier) {
51 return _strdup(static_cast<char*>(identifier));
52 }
53
54 NPObject* NPN_CreateObject(NPP npp, NPClass* class_vtable) {
55 UNREFERENCED_PARAMETER(npp);
56 ASSERT1(class_vtable);
57 NPObject* object = class_vtable->allocate(npp, class_vtable);
58 object->_class = class_vtable;
59 object->referenceCount = 1;
60 return object;
61 }
62
63 NPObject* NPN_RetainObject(NPObject* object) {
64 ASSERT1(object);
65 ++object->referenceCount;
66 return object;
67 }
68
69 void NPN_ReleaseObject(NPObject* object) {
70 ASSERT1(object);
71 ASSERT1(object->referenceCount > 0);
72 if (--object->referenceCount == 0) {
73 object->_class->deallocate(object);
74 }
75 }
76
77 void NPN_ReleaseVariantValue(NPVariant* variant) {
78 if (NPVARIANT_IS_STRING(*variant)) {
79 NPN_MemFree(const_cast<NPUTF8*>(variant->value.stringValue.UTF8Characters));
80 } else if (NPVARIANT_IS_OBJECT(*variant)) {
81 NPN_ReleaseObject(variant->value.objectValue);
82 }
83 VOID_TO_NPVARIANT(*variant);
84 return;
85 }
86
87 bool NPN_HasMethod(NPP npp, NPObject* object, NPIdentifier name) {
88 UNREFERENCED_PARAMETER(npp);
89 return object->_class->hasMethod(object, name);
90 }
91
92 bool NPN_Invoke(NPP npp, NPObject* object, NPIdentifier name,
93 const NPVariant* args, uint32_t arg_count, NPVariant* result) {
94 UNREFERENCED_PARAMETER(npp);
95 return object->_class->invoke(object, name, args, arg_count, result);
96 }
97
98 bool NPN_InvokeDefault(NPP npp, NPObject* object, const NPVariant* args,
99 uint32_t arg_count, NPVariant* result) {
100 UNREFERENCED_PARAMETER(npp);
101 return object->_class->invokeDefault(object, args, arg_count, result);
102 }
103
104 bool NPN_HasProperty(NPP npp, NPObject* object, NPIdentifier name) {
105 UNREFERENCED_PARAMETER(npp);
106 return object->_class->hasProperty(object, name);
107 }
108
109 bool NPN_GetProperty(NPP npp, NPObject* object, NPIdentifier name,
110 NPVariant* result) {
111 UNREFERENCED_PARAMETER(npp);
112 return object->_class->getProperty(object, name, result);
113 }
114
115 bool NPN_SetProperty(NPP npp, NPObject* object, NPIdentifier name,
116 const NPVariant* value) {
117 UNREFERENCED_PARAMETER(npp);
118 return object->_class->setProperty(object, name, value);
119 }
120
121 bool NPN_RemoveProperty(NPP npp, NPObject* object, NPIdentifier name) {
122 UNREFERENCED_PARAMETER(npp);
123 return object->_class->removeProperty(object, name);
124 }
125
126 bool NPN_Enumerate(NPP npp, NPObject* object, NPIdentifier** names,
127 uint32_t* count) {
128 UNREFERENCED_PARAMETER(npp);
129 return object->_class->enumerate(object, names, count);
130 }
131
132 bool NPN_Construct(NPP npp, NPObject* object, const NPVariant* args,
133 uint32_t arg_count, NPVariant* result) {
134 UNREFERENCED_PARAMETER(npp);
135 return object->_class->construct(object, args, arg_count, result);
136 }
137
138 void NPN_SetException(NPObject* object, const NPUTF8* message) {
139 UNREFERENCED_PARAMETER(object);
140 UNREFERENCED_PARAMETER(message);
141 }
142 } // extern "C"
OLDNEW
« no previous file with comments | « plugins/update/npapi/testing/stubs.h ('k') | plugins/update/npapi/urlpropbag.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698