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 9590002: JSONWriter cleanup: integrate pretty print into write options. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix merge conflict 7. Created 8 years, 9 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 void AppNotificationListToJSON(const AppNotificationList& list, 68 void AppNotificationListToJSON(const AppNotificationList& list,
69 std::string* result) { 69 std::string* result) {
70 ListValue list_value; 70 ListValue list_value;
71 AppNotificationList::const_iterator i; 71 AppNotificationList::const_iterator i;
72 for (i = list.begin(); i != list.end(); ++i) { 72 for (i = list.begin(); i != list.end(); ++i) {
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, false /* pretty_print */, 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 */)); 84 false /* allow_trailing_comma */));
85 if (!value.get() || value->GetType() != Value::TYPE_LIST) 85 if (!value.get() || value->GetType() != Value::TYPE_LIST)
86 return false; 86 return false;
87 87
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 options.create_if_missing = true; 220 options.create_if_missing = true;
221 leveldb::DB* db = NULL; 221 leveldb::DB* db = NULL;
222 leveldb::Status status = leveldb::DB::Open(options, os_path, &db); 222 leveldb::Status status = leveldb::DB::Open(options, os_path, &db);
223 if (!status.ok()) { 223 if (!status.ok()) {
224 LogLevelDbError(FROM_HERE, status); 224 LogLevelDbError(FROM_HERE, status);
225 return false; 225 return false;
226 } 226 }
227 db_.reset(db); 227 db_.reset(db);
228 return true; 228 return true;
229 } 229 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/app_notification.cc ('k') | chrome/browser/extensions/extension_browser_event_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698