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

Side by Side Diff: ppapi/shared_impl/private/ppb_x509_certificate_private_shared.cc

Issue 16915006: Convert most of extensions and some other random stuff to using the base namespace for Values. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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
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/private/ppb_x509_certificate_private_shared.h" 5 #include "ppapi/shared_impl/private/ppb_x509_certificate_private_shared.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ppapi/shared_impl/ppapi_globals.h" 8 #include "ppapi/shared_impl/ppapi_globals.h"
9 #include "ppapi/shared_impl/var.h" 9 #include "ppapi/shared_impl/var.h"
10 #include "ppapi/shared_impl/var_tracker.h" 10 #include "ppapi/shared_impl/var_tracker.h"
11 11
12 namespace ppapi { 12 namespace ppapi {
13 13
14 PPB_X509Certificate_Fields::PPB_X509Certificate_Fields() {} 14 PPB_X509Certificate_Fields::PPB_X509Certificate_Fields() {}
15 15
16 PPB_X509Certificate_Fields::PPB_X509Certificate_Fields( 16 PPB_X509Certificate_Fields::PPB_X509Certificate_Fields(
17 const PPB_X509Certificate_Fields& fields) { 17 const PPB_X509Certificate_Fields& fields) {
18 scoped_ptr<ListValue> new_values(fields.values_.DeepCopy()); 18 scoped_ptr<base::ListValue> new_values(fields.values_.DeepCopy());
19 values_.Swap(new_values.get()); 19 values_.Swap(new_values.get());
20 } 20 }
21 21
22 void PPB_X509Certificate_Fields::SetField( 22 void PPB_X509Certificate_Fields::SetField(
23 PP_X509Certificate_Private_Field field, 23 PP_X509Certificate_Private_Field field,
24 base::Value* value) { 24 base::Value* value) {
25 uint32_t index = static_cast<uint32_t>(field); 25 uint32_t index = static_cast<uint32_t>(field);
26 bool success = values_.Set(index, value); 26 bool success = values_.Set(index, value);
27 DCHECK(success); 27 DCHECK(success);
28 } 28 }
29 29
30 PP_Var PPB_X509Certificate_Fields::GetFieldAsPPVar( 30 PP_Var PPB_X509Certificate_Fields::GetFieldAsPPVar(
31 PP_X509Certificate_Private_Field field) const { 31 PP_X509Certificate_Private_Field field) const {
32 uint32_t index = static_cast<uint32_t>(field); 32 uint32_t index = static_cast<uint32_t>(field);
33 const base::Value* value; 33 const base::Value* value;
34 bool success = values_.Get(index, &value); 34 bool success = values_.Get(index, &value);
35 if (!success) { 35 if (!success) {
36 // Our list received might be smaller than the number of fields, so just 36 // Our list received might be smaller than the number of fields, so just
37 // return null if the index is OOB. 37 // return null if the index is OOB.
38 return PP_MakeNull(); 38 return PP_MakeNull();
39 } 39 }
40 40
41 switch (value->GetType()) { 41 switch (value->GetType()) {
42 case Value::TYPE_NULL: 42 case base::Value::TYPE_NULL:
43 return PP_MakeNull(); 43 return PP_MakeNull();
44 case Value::TYPE_BOOLEAN: { 44 case base::Value::TYPE_BOOLEAN: {
45 bool val; 45 bool val;
46 value->GetAsBoolean(&val); 46 value->GetAsBoolean(&val);
47 return PP_MakeBool(PP_FromBool(val)); 47 return PP_MakeBool(PP_FromBool(val));
48 } 48 }
49 case Value::TYPE_INTEGER: { 49 case base::Value::TYPE_INTEGER: {
50 int val; 50 int val;
51 value->GetAsInteger(&val); 51 value->GetAsInteger(&val);
52 return PP_MakeInt32(val); 52 return PP_MakeInt32(val);
53 } 53 }
54 case Value::TYPE_DOUBLE: { 54 case base::Value::TYPE_DOUBLE: {
55 double val; 55 double val;
56 value->GetAsDouble(&val); 56 value->GetAsDouble(&val);
57 return PP_MakeDouble(val); 57 return PP_MakeDouble(val);
58 } 58 }
59 case Value::TYPE_STRING: { 59 case base::Value::TYPE_STRING: {
60 std::string val; 60 std::string val;
61 value->GetAsString(&val); 61 value->GetAsString(&val);
62 return StringVar::StringToPPVar(val); 62 return StringVar::StringToPPVar(val);
63 } 63 }
64 case Value::TYPE_BINARY: { 64 case base::Value::TYPE_BINARY: {
65 const base::BinaryValue* binary = 65 const base::BinaryValue* binary =
66 static_cast<const base::BinaryValue*>(value); 66 static_cast<const base::BinaryValue*>(value);
67 uint32_t size = static_cast<uint32_t>(binary->GetSize()); 67 uint32_t size = static_cast<uint32_t>(binary->GetSize());
68 const char* buffer = binary->GetBuffer(); 68 const char* buffer = binary->GetBuffer();
69 PP_Var array_buffer = 69 PP_Var array_buffer =
70 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar(size, 70 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar(size,
71 buffer); 71 buffer);
72 return array_buffer; 72 return array_buffer;
73 } 73 }
74 case Value::TYPE_DICTIONARY: 74 case base::Value::TYPE_DICTIONARY:
75 case Value::TYPE_LIST: 75 case base::Value::TYPE_LIST:
76 // Not handled. 76 // Not handled.
77 break; 77 break;
78 } 78 }
79 79
80 // Should not reach here. 80 // Should not reach here.
81 CHECK(false); 81 CHECK(false);
82 return PP_MakeUndefined(); 82 return PP_MakeUndefined();
83 } 83 }
84 84
85 //------------------------------------------------------------------------------ 85 //------------------------------------------------------------------------------
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 const std::vector<char>& der, 137 const std::vector<char>& der,
138 PPB_X509Certificate_Fields* result) { 138 PPB_X509Certificate_Fields* result) {
139 // A concrete PPB_X509Certificate_Private_Shared should only ever be 139 // A concrete PPB_X509Certificate_Private_Shared should only ever be
140 // constructed by passing in PPB_X509Certificate_Fields, in which case it is 140 // constructed by passing in PPB_X509Certificate_Fields, in which case it is
141 // already initialized. 141 // already initialized.
142 CHECK(false); 142 CHECK(false);
143 return false; 143 return false;
144 } 144 }
145 145
146 } // namespace ppapi 146 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698