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

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

Issue 1308013005: Add scoped_ptr-safe base::Value to Dictionary/List conversion functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Made conversions static members. Created 5 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 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 <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 // Tracking down http://crbug.com/121424 54 // Tracking down http://crbug.com/121424
55 char buf[128]; 55 char buf[128];
56 base::snprintf(buf, arraysize(buf), "%s: (%d) '%s'", 56 base::snprintf(buf, arraysize(buf), "%s: (%d) '%s'",
57 name.c_str(), 57 name.c_str(),
58 result.get() ? result->GetType() : -1, 58 result.get() ? result->GetType() : -1,
59 error_message.c_str()); 59 error_message.c_str());
60 60
61 CHECK(result.get()) << error_message << " for schema " << schema; 61 CHECK(result.get()) << error_message << " for schema " << schema;
62 CHECK(result->IsType(base::Value::TYPE_LIST)) << " for schema " << schema; 62 CHECK(result->IsType(base::Value::TYPE_LIST)) << " for schema " << schema;
63 return scoped_ptr<base::ListValue>(static_cast<base::ListValue*>( 63 return base::ListValue::From(result.Pass());
64 result.release()));
65 } 64 }
66 65
67 const base::DictionaryValue* FindListItem(const base::ListValue* list, 66 const base::DictionaryValue* FindListItem(const base::ListValue* list,
68 const std::string& property_name, 67 const std::string& property_name,
69 const std::string& property_value) { 68 const std::string& property_value) {
70 for (size_t i = 0; i < list->GetSize(); ++i) { 69 for (size_t i = 0; i < list->GetSize(); ++i) {
71 const base::DictionaryValue* item = NULL; 70 const base::DictionaryValue* item = NULL;
72 CHECK(list->GetDictionary(i, &item)) 71 CHECK(list->GetDictionary(i, &item))
73 << property_value << "/" << property_name; 72 << property_value << "/" << property_name;
74 std::string value; 73 std::string value;
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 break; 384 break;
386 385
387 api_name_candidate = api_name_candidate.substr(0, last_dot_index); 386 api_name_candidate = api_name_candidate.substr(0, last_dot_index);
388 } 387 }
389 388
390 *child_name = ""; 389 *child_name = "";
391 return std::string(); 390 return std::string();
392 } 391 }
393 392
394 } // namespace extensions 393 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api_test_utils.cc ('k') | extensions/common/features/json_feature_provider_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698