OLD | NEW |
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 "components/filesystem/public/cpp/prefs/filesystem_json_pref_store.h" | 5 #include "components/filesystem/public/cpp/prefs/filesystem_json_pref_store.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 mojo::Array<uint8_t> contents) { | 421 mojo::Array<uint8_t> contents) { |
422 scoped_ptr<FilesystemJsonPrefStore::ReadResult> read_result( | 422 scoped_ptr<FilesystemJsonPrefStore::ReadResult> read_result( |
423 new FilesystemJsonPrefStore::ReadResult); | 423 new FilesystemJsonPrefStore::ReadResult); |
424 // TODO(erg): Needs even better error handling. | 424 // TODO(erg): Needs even better error handling. |
425 switch (err) { | 425 switch (err) { |
426 case FileError::IN_USE: | 426 case FileError::IN_USE: |
427 case FileError::ACCESS_DENIED: { | 427 case FileError::ACCESS_DENIED: { |
428 read_only_ = true; | 428 read_only_ = true; |
429 break; | 429 break; |
430 } | 430 } |
| 431 case FileError::FAILED: |
431 case FileError::NOT_FOUND: { | 432 case FileError::NOT_FOUND: { |
432 // If the file just doesn't exist, maybe this is the first run. Just | 433 // If the file just doesn't exist, maybe this is the first run. Just |
433 // don't pass a value. | 434 // don't pass a value. |
434 read_result->error = PREF_READ_ERROR_NO_FILE; | 435 read_result->error = PREF_READ_ERROR_NO_FILE; |
435 break; | 436 break; |
436 } | 437 } |
437 default: { | 438 default: { |
438 int error_code; | 439 int error_code; |
439 std::string error_msg; | 440 std::string error_msg; |
440 JSONStringValueDeserializer deserializer(base::StringPiece( | 441 JSONStringValueDeserializer deserializer(base::StringPiece( |
441 reinterpret_cast<char*>(&contents.front()), contents.size())); | 442 reinterpret_cast<char*>(&contents.front()), contents.size())); |
442 read_result->value = deserializer.Deserialize(&error_code, &error_msg); | 443 read_result->value = deserializer.Deserialize(&error_code, &error_msg); |
443 read_result->error = HandleReadErrors(read_result->value.get()); | 444 read_result->error = HandleReadErrors(read_result->value.get()); |
444 } | 445 } |
445 } | 446 } |
446 | 447 |
447 preferences_file_.reset(); | 448 preferences_file_.reset(); |
448 | 449 |
449 OnFileRead(std::move(read_result)); | 450 OnFileRead(std::move(read_result)); |
450 } | 451 } |
451 | 452 |
452 } // namespace filesystem | 453 } // namespace filesystem |
OLD | NEW |