| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |