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

Side by Side Diff: extensions/browser/computed_hashes.cc

Issue 1131113004: Convert JsonWriter::Write to taking a const ref for the in-param (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: another rebase Created 5 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/browser/computed_hashes.h" 5 #include "extensions/browser/computed_hashes.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 block_hashes->AppendString(encoded); 149 block_hashes->AppendString(encoded);
150 } 150 }
151 } 151 }
152 152
153 bool ComputedHashes::Writer::WriteToFile(const base::FilePath& path) { 153 bool ComputedHashes::Writer::WriteToFile(const base::FilePath& path) {
154 std::string json; 154 std::string json;
155 base::DictionaryValue top_dictionary; 155 base::DictionaryValue top_dictionary;
156 top_dictionary.SetInteger(kVersionKey, kVersion); 156 top_dictionary.SetInteger(kVersionKey, kVersion);
157 top_dictionary.Set(kFileHashesKey, file_list_.release()); 157 top_dictionary.Set(kFileHashesKey, file_list_.release());
158 158
159 if (!base::JSONWriter::Write(&top_dictionary, &json)) 159 if (!base::JSONWriter::Write(top_dictionary, &json))
160 return false; 160 return false;
161 int written = base::WriteFile(path, json.data(), json.size()); 161 int written = base::WriteFile(path, json.data(), json.size());
162 if (static_cast<unsigned>(written) != json.size()) { 162 if (static_cast<unsigned>(written) != json.size()) {
163 LOG(ERROR) << "Error writing " << path.AsUTF8Unsafe() 163 LOG(ERROR) << "Error writing " << path.AsUTF8Unsafe()
164 << " ; write result:" << written << " expected:" << json.size(); 164 << " ; write result:" << written << " expected:" << json.size();
165 return false; 165 return false;
166 } 166 }
167 return true; 167 return true;
168 } 168 }
169 169
(...skipping 18 matching lines...) Expand all
188 188
189 // If |contents| is empty, then we want to just exit here. 189 // If |contents| is empty, then we want to just exit here.
190 if (bytes_to_read == 0) 190 if (bytes_to_read == 0)
191 break; 191 break;
192 192
193 offset += bytes_to_read; 193 offset += bytes_to_read;
194 } while (offset < contents.size()); 194 } while (offset < contents.size());
195 } 195 }
196 196
197 } // namespace extensions 197 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/web_request/web_request_api.cc ('k') | extensions/browser/value_store/leveldb_value_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698