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

Side by Side Diff: chrome/browser/extensions/app_notification_storage.cc

Issue 9960077: Modify the base::JSONReader interface to take a set of options rather than a boolean flag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 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 | 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 "chrome/browser/extensions/app_notification_storage.h" 5 #include "chrome/browser/extensions/app_notification_storage.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 DictionaryValue* dictionary = new DictionaryValue(); 73 DictionaryValue* dictionary = new DictionaryValue();
74 (*i)->ToDictionaryValue(dictionary); 74 (*i)->ToDictionaryValue(dictionary);
75 list_value.Append(dictionary); 75 list_value.Append(dictionary);
76 } 76 }
77 JSONWriter::Write(&list_value, result); 77 JSONWriter::Write(&list_value, result);
78 } 78 }
79 79
80 bool JSONToAppNotificationList(const std::string& json, 80 bool JSONToAppNotificationList(const std::string& json,
81 AppNotificationList* list) { 81 AppNotificationList* list) {
82 CHECK(list); 82 CHECK(list);
83 scoped_ptr<Value> value(JSONReader::Read(json, 83 scoped_ptr<Value> value(JSONReader::Read(json));
84 false /* allow_trailing_comma */));
85 if (!value.get() || value->GetType() != Value::TYPE_LIST) 84 if (!value.get() || value->GetType() != Value::TYPE_LIST)
86 return false; 85 return false;
87 86
88 ListValue* list_value = static_cast<ListValue*>(value.get()); 87 ListValue* list_value = static_cast<ListValue*>(value.get());
89 for (size_t i = 0; i < list_value->GetSize(); i++) { 88 for (size_t i = 0; i < list_value->GetSize(); i++) {
90 Value* item = NULL; 89 Value* item = NULL;
91 if (!list_value->Get(i, &item) || !item || 90 if (!list_value->Get(i, &item) || !item ||
92 item->GetType() != Value::TYPE_DICTIONARY) 91 item->GetType() != Value::TYPE_DICTIONARY)
93 return false; 92 return false;
94 DictionaryValue* dictionary = static_cast<DictionaryValue*>(item); 93 DictionaryValue* dictionary = static_cast<DictionaryValue*>(item);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 options.create_if_missing = true; 219 options.create_if_missing = true;
221 leveldb::DB* db = NULL; 220 leveldb::DB* db = NULL;
222 leveldb::Status status = leveldb::DB::Open(options, os_path, &db); 221 leveldb::Status status = leveldb::DB::Open(options, os_path, &db);
223 if (!status.ok()) { 222 if (!status.ok()) {
224 LogLevelDbError(FROM_HERE, status); 223 LogLevelDbError(FROM_HERE, status);
225 return false; 224 return false;
226 } 225 }
227 db_.reset(db); 226 db_.reset(db);
228 return true; 227 return true;
229 } 228 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698