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

Side by Side Diff: extensions/common/extension_api.cc

Issue 2255953002: [Extensions] Make ExtensionAPI use unique_ptrs instead of linked_ptrs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 | « extensions/common/extension_api.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "extensions/common/extension_api.h" 5 #include "extensions/common/extension_api.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <string> 10 #include <string>
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } 212 }
213 213
214 void ExtensionAPI::LoadSchema(const std::string& name, 214 void ExtensionAPI::LoadSchema(const std::string& name,
215 const base::StringPiece& schema) { 215 const base::StringPiece& schema) {
216 std::unique_ptr<base::ListValue> schema_list(LoadSchemaList(name, schema)); 216 std::unique_ptr<base::ListValue> schema_list(LoadSchemaList(name, schema));
217 std::string schema_namespace; 217 std::string schema_namespace;
218 extensions::ExtensionsClient* extensions_client = 218 extensions::ExtensionsClient* extensions_client =
219 extensions::ExtensionsClient::Get(); 219 extensions::ExtensionsClient::Get();
220 DCHECK(extensions_client); 220 DCHECK(extensions_client);
221 while (!schema_list->empty()) { 221 while (!schema_list->empty()) {
222 base::DictionaryValue* schema = NULL; 222 std::unique_ptr<base::DictionaryValue> schema;
223 { 223 {
224 std::unique_ptr<base::Value> value; 224 std::unique_ptr<base::Value> val;
225 schema_list->Remove(schema_list->GetSize() - 1, &value); 225 schema_list->Erase(schema_list->begin(), &val);
226 CHECK(value.release()->GetAsDictionary(&schema)); 226 schema = base::DictionaryValue::From(std::move(val));
227 CHECK(schema);
227 } 228 }
228
229 CHECK(schema->GetString("namespace", &schema_namespace)); 229 CHECK(schema->GetString("namespace", &schema_namespace));
230 PrefixWithNamespace(schema_namespace, schema); 230 PrefixWithNamespace(schema_namespace, schema.get());
231 schemas_[schema_namespace] = make_linked_ptr(schema); 231 schemas_[schema_namespace] = std::move(schema);
232 if (!extensions_client->IsAPISchemaGenerated(schema_namespace)) 232 if (!extensions_client->IsAPISchemaGenerated(schema_namespace))
233 CHECK_EQ(1u, unloaded_schemas_.erase(schema_namespace)); 233 CHECK_EQ(1u, unloaded_schemas_.erase(schema_namespace));
234 } 234 }
235 } 235 }
236 236
237 ExtensionAPI::ExtensionAPI() : default_configuration_initialized_(false) { 237 ExtensionAPI::ExtensionAPI() : default_configuration_initialized_(false) {
238 } 238 }
239 239
240 ExtensionAPI::~ExtensionAPI() { 240 ExtensionAPI::~ExtensionAPI() {
241 } 241 }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 break; 388 break;
389 389
390 api_name_candidate = api_name_candidate.substr(0, last_dot_index); 390 api_name_candidate = api_name_candidate.substr(0, last_dot_index);
391 } 391 }
392 392
393 *child_name = ""; 393 *child_name = "";
394 return std::string(); 394 return std::string();
395 } 395 }
396 396
397 } // namespace extensions 397 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/extension_api.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698