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

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

Issue 1864293002: Convert //ppapi to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more nullptr Created 4 years, 8 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/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<base::ListValue> new_values(fields.values_.DeepCopy()); 18 std::unique_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 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 PP_Bool PPB_X509Certificate_Private_Shared::Initialize(const char* bytes, 108 PP_Bool PPB_X509Certificate_Private_Shared::Initialize(const char* bytes,
109 uint32_t length) { 109 uint32_t length) {
110 // The certificate should be immutable once initialized. 110 // The certificate should be immutable once initialized.
111 if (fields_.get()) 111 if (fields_.get())
112 return PP_FALSE; 112 return PP_FALSE;
113 113
114 if (!bytes || length == 0) 114 if (!bytes || length == 0)
115 return PP_FALSE; 115 return PP_FALSE;
116 116
117 std::vector<char> der(bytes, bytes + length); 117 std::vector<char> der(bytes, bytes + length);
118 scoped_ptr<PPB_X509Certificate_Fields> fields( 118 std::unique_ptr<PPB_X509Certificate_Fields> fields(
119 new PPB_X509Certificate_Fields()); 119 new PPB_X509Certificate_Fields());
120 bool success = ParseDER(der, fields.get()); 120 bool success = ParseDER(der, fields.get());
121 if (success) { 121 if (success) {
122 fields_.swap(fields); 122 fields_.swap(fields);
123 return PP_TRUE; 123 return PP_TRUE;
124 } 124 }
125 return PP_FALSE; 125 return PP_FALSE;
126 } 126 }
127 127
128 PP_Var PPB_X509Certificate_Private_Shared::GetField( 128 PP_Var PPB_X509Certificate_Private_Shared::GetField(
129 PP_X509Certificate_Private_Field field) { 129 PP_X509Certificate_Private_Field field) {
130 if (!fields_.get()) 130 if (!fields_.get())
131 return PP_MakeUndefined(); 131 return PP_MakeUndefined();
132 132
133 return fields_->GetFieldAsPPVar(field); 133 return fields_->GetFieldAsPPVar(field);
134 } 134 }
135 135
136 bool PPB_X509Certificate_Private_Shared::ParseDER( 136 bool PPB_X509Certificate_Private_Shared::ParseDER(
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
« no previous file with comments | « ppapi/shared_impl/private/ppb_x509_certificate_private_shared.h ('k') | ppapi/shared_impl/proxy_lock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698