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

Side by Side Diff: extensions/utility/unpacker.cc

Issue 2881453002: DNR Prototype: With flatbuffers
Patch Set: -- Created 3 years, 6 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
« no previous file with comments | « extensions/utility/DEPS ('k') | third_party/flatbuffers/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "extensions/utility/unpacker.h" 5 #include "extensions/utility/unpacker.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <set> 10 #include <set>
11 #include <tuple> 11 #include <tuple>
12 #include <utility> 12 #include <utility>
13
14 #include "base/files/file_enumerator.h" 13 #include "base/files/file_enumerator.h"
15 #include "base/files/file_util.h" 14 #include "base/files/file_util.h"
16 #include "base/files/scoped_temp_dir.h" 15 #include "base/files/scoped_temp_dir.h"
17 #include "base/i18n/rtl.h" 16 #include "base/i18n/rtl.h"
18 #include "base/json/json_file_value_serializer.h" 17 #include "base/json/json_file_value_serializer.h"
19 #include "base/numerics/safe_conversions.h" 18 #include "base/numerics/safe_conversions.h"
20 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
21 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
22 #include "base/threading/thread.h" 21 #include "base/threading/thread.h"
23 #include "base/values.h" 22 #include "base/values.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 return false; // Error was already reported. 227 return false; // Error was already reported.
229 } 228 }
230 229
231 // Parse all message catalogs (if any). 230 // Parse all message catalogs (if any).
232 parsed_catalogs_.reset(new base::DictionaryValue); 231 parsed_catalogs_.reset(new base::DictionaryValue);
233 if (!LocaleInfo::GetDefaultLocale(extension.get()).empty()) { 232 if (!LocaleInfo::GetDefaultLocale(extension.get()).empty()) {
234 if (!ReadAllMessageCatalogs()) 233 if (!ReadAllMessageCatalogs())
235 return false; // Error was already reported. 234 return false; // Error was already reported.
236 } 235 }
237 236
237 // TODO cleanup files if needed somewhere.
238 if (!file_util::IndexAndPersistRulesetIfNeeded(
239 extension.get(), file_util::GetIndexedRulesetPath(working_dir_),
240 &error)) {
241 return false; // error should be populated by the above call.
242 }
243
238 return DumpImagesToFile() && DumpMessageCatalogsToFile(); 244 return DumpImagesToFile() && DumpMessageCatalogsToFile();
239 } 245 }
240 246
241 bool Unpacker::DumpImagesToFile() { 247 bool Unpacker::DumpImagesToFile() {
242 IPC::Message pickle; // We use a Message so we can use WriteParam. 248 IPC::Message pickle; // We use a Message so we can use WriteParam.
243 IPC::WriteParam(&pickle, internal_data_->decoded_images); 249 IPC::WriteParam(&pickle, internal_data_->decoded_images);
244 250
245 base::FilePath path = working_dir_.AppendASCII(kDecodedImagesFilename); 251 base::FilePath path = working_dir_.AppendASCII(kDecodedImagesFilename);
246 if (!WritePickle(pickle, path)) { 252 if (!WritePickle(pickle, path)) {
247 SetError("Could not write image data to disk."); 253 SetError("Could not write image data to disk.");
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 331
326 void Unpacker::SetError(const std::string& error) { 332 void Unpacker::SetError(const std::string& error) {
327 SetUTF16Error(base::UTF8ToUTF16(error)); 333 SetUTF16Error(base::UTF8ToUTF16(error));
328 } 334 }
329 335
330 void Unpacker::SetUTF16Error(const base::string16& error) { 336 void Unpacker::SetUTF16Error(const base::string16& error) {
331 error_message_ = error; 337 error_message_ = error;
332 } 338 }
333 339
334 } // namespace extensions 340 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/utility/DEPS ('k') | third_party/flatbuffers/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698