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

Side by Side Diff: ppapi/shared_impl/var.cc

Issue 18599005: [PPAPI] Added PP_VARTYPE_RESOURCE as a PP_VarType enum value. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix unittest_utils comparison of resource vars. Created 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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/shared_impl/var.h" 5 #include "ppapi/shared_impl/var.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/stringprintf.h"
12 #include "ppapi/c/pp_var.h" 13 #include "ppapi/c/pp_var.h"
13 #include "ppapi/shared_impl/ppapi_globals.h" 14 #include "ppapi/shared_impl/ppapi_globals.h"
15 #include "ppapi/shared_impl/resource_var.h"
14 #include "ppapi/shared_impl/var_tracker.h" 16 #include "ppapi/shared_impl/var_tracker.h"
15 17
16 namespace ppapi { 18 namespace ppapi {
17 19
18 // Var ------------------------------------------------------------------------- 20 // Var -------------------------------------------------------------------------
19 21
20 Var::Var() : var_id_(0) { 22 Var::Var() : var_id_(0) {
21 } 23 }
22 24
23 Var::~Var() { 25 Var::~Var() {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 return result; 57 return result;
56 } 58 }
57 case PP_VARTYPE_OBJECT: 59 case PP_VARTYPE_OBJECT:
58 return "[Object]"; 60 return "[Object]";
59 case PP_VARTYPE_ARRAY: 61 case PP_VARTYPE_ARRAY:
60 return "[Array]"; 62 return "[Array]";
61 case PP_VARTYPE_DICTIONARY: 63 case PP_VARTYPE_DICTIONARY:
62 return "[Dictionary]"; 64 return "[Dictionary]";
63 case PP_VARTYPE_ARRAY_BUFFER: 65 case PP_VARTYPE_ARRAY_BUFFER:
64 return "[Array buffer]"; 66 return "[Array buffer]";
67 case PP_VARTYPE_RESOURCE: {
68 ResourceVar* resource(ResourceVar::FromPPVar(var));
69 if (!resource)
70 return "[Invalid resource]";
71
72 if (resource->pp_resource()) {
73 return base::StringPrintf("[Resource %d]", resource->pp_resource());
74 } else if (resource->creation_message().type() != 0) {
raymes 2013/09/11 22:52:29 This makes me wonder whether maybe we should have
yzshen1 2013/09/11 22:57:11 Or maybe we could have some boolean method such as
Matt Giuca 2013/09/12 07:08:24 Yeah OK. I think I'll add IsPending (it doesn't se
75 return base::StringPrintf("[Pending resource]");
76 } else {
77 return "[Null resource]";
78 }
79 }
65 default: 80 default:
66 return "[Invalid var]"; 81 return "[Invalid var]";
67 } 82 }
68 } 83 }
69 84
70 StringVar* Var::AsStringVar() { 85 StringVar* Var::AsStringVar() {
71 return NULL; 86 return NULL;
72 } 87 }
73 88
74 ArrayBufferVar* Var::AsArrayBufferVar() { 89 ArrayBufferVar* Var::AsArrayBufferVar() {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 return NULL; 221 return NULL;
207 scoped_refptr<Var> var_object( 222 scoped_refptr<Var> var_object(
208 PpapiGlobals::Get()->GetVarTracker()->GetVar(var)); 223 PpapiGlobals::Get()->GetVarTracker()->GetVar(var));
209 if (!var_object.get()) 224 if (!var_object.get())
210 return NULL; 225 return NULL;
211 return var_object->AsArrayBufferVar(); 226 return var_object->AsArrayBufferVar();
212 } 227 }
213 228
214 } // namespace ppapi 229 } // namespace ppapi
215 230
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698