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

Side by Side Diff: components/filesystem/public/cpp/prefs/filesystem_json_pref_store.cc

Issue 1637113003: Add simplistic screenlock application. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 10 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 | « no previous file | mash/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 "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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 void FilesystemJsonPrefStore::PerformWrite() { 320 void FilesystemJsonPrefStore::PerformWrite() {
321 if (!directory_) { 321 if (!directory_) {
322 OpenFilesystem( 322 OpenFilesystem(
323 Bind(&FilesystemJsonPrefStore::OnTempFileWriteStart, AsWeakPtr())); 323 Bind(&FilesystemJsonPrefStore::OnTempFileWriteStart, AsWeakPtr()));
324 } else { 324 } else {
325 OnTempFileWriteStart(); 325 OnTempFileWriteStart();
326 } 326 }
327 } 327 }
328 328
329 void FilesystemJsonPrefStore::OpenFilesystem(base::Closure callback) { 329 void FilesystemJsonPrefStore::OpenFilesystem(base::Closure callback) {
330 filesystem::FileSystemClientPtr client;
331 binding_.Bind(GetProxy(&client));
332
330 filesystem_->OpenFileSystem( 333 filesystem_->OpenFileSystem(
331 "origin", GetProxy(&directory_), binding_.CreateInterfacePtrAndBind(), 334 "origin", GetProxy(&directory_), std::move(client),
332 base::Bind(&FilesystemJsonPrefStore::OnOpenFilesystem, AsWeakPtr(), 335 base::Bind(&FilesystemJsonPrefStore::OnOpenFilesystem, AsWeakPtr(),
333 callback)); 336 callback));
334 } 337 }
335 338
336 void FilesystemJsonPrefStore::OnOpenFilesystem(base::Closure callback, 339 void FilesystemJsonPrefStore::OnOpenFilesystem(base::Closure callback,
337 FileError err) { 340 FileError err) {
338 if (err != FileError::OK) { 341 if (err != FileError::OK) {
339 // Do real error checking. 342 // Do real error checking.
340 NOTIMPLEMENTED(); 343 NOTIMPLEMENTED();
341 return; 344 return;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 mojo::Array<uint8_t> contents) { 421 mojo::Array<uint8_t> contents) {
419 scoped_ptr<FilesystemJsonPrefStore::ReadResult> read_result( 422 scoped_ptr<FilesystemJsonPrefStore::ReadResult> read_result(
420 new FilesystemJsonPrefStore::ReadResult); 423 new FilesystemJsonPrefStore::ReadResult);
421 // TODO(erg): Needs even better error handling. 424 // TODO(erg): Needs even better error handling.
422 switch (err) { 425 switch (err) {
423 case FileError::IN_USE: 426 case FileError::IN_USE:
424 case FileError::ACCESS_DENIED: { 427 case FileError::ACCESS_DENIED: {
425 read_only_ = true; 428 read_only_ = true;
426 break; 429 break;
427 } 430 }
428 case FileError::FAILED:
429 case FileError::NOT_FOUND: { 431 case FileError::NOT_FOUND: {
430 // If the file just doesn't exist, maybe this is the first run. Just 432 // If the file just doesn't exist, maybe this is the first run. Just
431 // don't pass a value. 433 // don't pass a value.
432 read_result->error = PREF_READ_ERROR_NO_FILE; 434 read_result->error = PREF_READ_ERROR_NO_FILE;
433 break; 435 break;
434 } 436 }
435 default: { 437 default: {
436 int error_code; 438 int error_code;
437 std::string error_msg; 439 std::string error_msg;
438 JSONStringValueDeserializer deserializer(base::StringPiece( 440 JSONStringValueDeserializer deserializer(base::StringPiece(
439 reinterpret_cast<char*>(&contents.front()), contents.size())); 441 reinterpret_cast<char*>(&contents.front()), contents.size()));
440 read_result->value = deserializer.Deserialize(&error_code, &error_msg); 442 read_result->value = deserializer.Deserialize(&error_code, &error_msg);
441 read_result->error = HandleReadErrors(read_result->value.get()); 443 read_result->error = HandleReadErrors(read_result->value.get());
442 } 444 }
443 } 445 }
444 446
445 preferences_file_.reset(); 447 preferences_file_.reset();
446 448
447 OnFileRead(std::move(read_result)); 449 OnFileRead(std::move(read_result));
448 } 450 }
449 451
450 } // namespace filesystem 452 } // namespace filesystem
OLDNEW
« no previous file with comments | « no previous file | mash/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698