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

Side by Side Diff: ppapi/thunk/enter.cc

Issue 9113044: Convert to new enter method (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: PATCH DESCRIPTIONS ARE A STUPID WASTE OF TIME 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
« no previous file with comments | « ppapi/thunk/enter.h ('k') | ppapi/thunk/ppb_audio_input_thunk.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/thunk/enter.h" 5 #include "ppapi/thunk/enter.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 return PpapiGlobals::Get()->GetResourceTracker()->GetResource(resource); 76 return PpapiGlobals::Get()->GetResourceTracker()->GetResource(resource);
77 } 77 }
78 78
79 void EnterBase::SetStateForResourceError(PP_Resource pp_resource, 79 void EnterBase::SetStateForResourceError(PP_Resource pp_resource,
80 Resource* resource_base, 80 Resource* resource_base,
81 void* object, 81 void* object,
82 bool report_error) { 82 bool report_error) {
83 if (object) 83 if (object)
84 return; // Everything worked. 84 return; // Everything worked.
85 85
86 retval_ = PP_ERROR_BADRESOURCE; 86 if (callback_.func) {
87 // Required callback, issue the async completion.
88 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
89 callback_.func, callback_.user_data,
90 static_cast<int32_t>(PP_ERROR_BADRESOURCE)));
91 callback_ = PP_BlockUntilComplete();
92 retval_ = PP_OK_COMPLETIONPENDING;
93 } else {
94 retval_ = PP_ERROR_BADRESOURCE;
95 }
87 96
88 // We choose to silently ignore the error when the pp_resource is null 97 // We choose to silently ignore the error when the pp_resource is null
89 // because this is a pretty common case and we don't want to have lots 98 // because this is a pretty common case and we don't want to have lots
90 // of errors in the log. This should be an obvious case to debug. 99 // of errors in the log. This should be an obvious case to debug.
91 if (report_error && pp_resource) { 100 if (report_error && pp_resource) {
92 std::string message; 101 std::string message;
93 if (resource_base) { 102 if (resource_base) {
94 message = base::StringPrintf( 103 message = base::StringPrintf(
95 "0x%X is not the correct type for this function.", 104 "0x%X is not the correct type for this function.",
96 pp_resource); 105 pp_resource);
97 } else { 106 } else {
98 message = base::StringPrintf( 107 message = base::StringPrintf(
99 "0x%X is not a valid resource ID.", 108 "0x%X is not a valid resource ID.",
100 pp_resource); 109 pp_resource);
101 } 110 }
102 PpapiGlobals::Get()->BroadcastLogWithSource(0, PP_LOGLEVEL_ERROR, 111 PpapiGlobals::Get()->BroadcastLogWithSource(0, PP_LOGLEVEL_ERROR,
103 std::string(), message); 112 std::string(), message);
104 } 113 }
105 } 114 }
106 115
116 void EnterBase::SetStateForFunctionError(PP_Instance pp_instance,
117 void* object,
118 bool report_error) {
119 if (object)
120 return; // Everything worked.
121
122 if (callback_.func) {
123 // Required callback, issue the async completion.
124 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
125 callback_.func, callback_.user_data,
126 static_cast<int32_t>(PP_ERROR_BADARGUMENT)));
127 callback_ = PP_BlockUntilComplete();
128 retval_ = PP_OK_COMPLETIONPENDING;
129 } else {
130 retval_ = PP_ERROR_BADARGUMENT;
131 }
132
133 // We choose to silently ignore the error when the pp_instance is null as
134 // for PP_Resources above.
135 if (report_error && pp_instance) {
136 std::string message;
137 message = base::StringPrintf(
138 "0x%X is not a valid instance ID.",
139 pp_instance);
140 PpapiGlobals::Get()->BroadcastLogWithSource(0, PP_LOGLEVEL_ERROR,
141 std::string(), message);
142 }
143 }
144
107 } // namespace subtle 145 } // namespace subtle
108 146
109 EnterResourceCreation::EnterResourceCreation(PP_Instance instance) 147 EnterResourceCreation::EnterResourceCreation(PP_Instance instance)
110 : EnterFunctionNoLock<ResourceCreationAPI>(instance, true) { 148 : EnterFunctionNoLock<ResourceCreationAPI>(instance, true) {
111 } 149 }
112 150
113 EnterResourceCreation::~EnterResourceCreation() { 151 EnterResourceCreation::~EnterResourceCreation() {
114 } 152 }
115 153
116 EnterInstance::EnterInstance(PP_Instance instance) 154 EnterInstance::EnterInstance(PP_Instance instance)
117 : EnterFunctionNoLock<PPB_Instance_FunctionAPI>(instance, true) { 155 : EnterFunction<PPB_Instance_FunctionAPI>(instance, true) {
156 }
157
158 EnterInstance::EnterInstance(PP_Instance instance,
159 const PP_CompletionCallback& callback)
160 : EnterFunction<PPB_Instance_FunctionAPI>(instance, callback, true) {
118 } 161 }
119 162
120 EnterInstance::~EnterInstance() { 163 EnterInstance::~EnterInstance() {
121 } 164 }
122 165
123 } // namespace thunk 166 } // namespace thunk
124 } // namespace ppapi 167 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/thunk/enter.h ('k') | ppapi/thunk/ppb_audio_input_thunk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698