| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/sync_file_system/local/root_delete_helper.h" | 5 #include "chrome/browser/sync_file_system/local/root_delete_helper.h" |
| 6 | 6 |
| 7 #include "base/sequenced_task_runner.h" | 7 #include "base/sequenced_task_runner.h" |
| 8 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h" | 8 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h" |
| 9 #include "chrome/browser/sync_file_system/local/local_file_sync_status.h" | 9 #include "chrome/browser/sync_file_system/local/local_file_sync_status.h" |
| 10 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" | 10 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 // Ignore errors, no idea how to deal with it. | 69 // Ignore errors, no idea how to deal with it. |
| 70 | 70 |
| 71 DCHECK(!sync_status_->IsWritable(url_)); | 71 DCHECK(!sync_status_->IsWritable(url_)); |
| 72 DCHECK(!sync_status_->IsWriting(url_)); | 72 DCHECK(!sync_status_->IsWriting(url_)); |
| 73 | 73 |
| 74 // All writes to the entire file system must be now blocked, so we have | 74 // All writes to the entire file system must be now blocked, so we have |
| 75 // to be able to safely reset the local changes and sync statuses for it. | 75 // to be able to safely reset the local changes and sync statuses for it. |
| 76 // TODO(kinuko): This should be probably automatically handled in | 76 // TODO(kinuko): This should be probably automatically handled in |
| 77 // DeleteFileSystem via QuotaUtil::DeleteOriginDataOnFileThread. | 77 // DeleteFileSystem via QuotaUtil::DeleteOriginDataOnFileThread. |
| 78 file_system_context_->default_file_task_runner()->PostTaskAndReply( | 78 file_system_context_->default_file_task_runner()->PostTaskAndReply( |
| 79 FROM_HERE, base::Bind(&ResetFileChangeTracker, | 79 FROM_HERE, |
| 80 base::RetainedRef(file_system_context_), url_), | 80 base::BindOnce(&ResetFileChangeTracker, |
| 81 base::Bind(&RootDeleteHelper::DidResetFileChangeTracker, | 81 base::RetainedRef(file_system_context_), url_), |
| 82 weak_factory_.GetWeakPtr())); | 82 base::BindOnce(&RootDeleteHelper::DidResetFileChangeTracker, |
| 83 weak_factory_.GetWeakPtr())); |
| 83 } | 84 } |
| 84 | 85 |
| 85 void RootDeleteHelper::DidResetFileChangeTracker() { | 86 void RootDeleteHelper::DidResetFileChangeTracker() { |
| 86 DCHECK(!sync_status_->IsWritable(url_)); | 87 DCHECK(!sync_status_->IsWritable(url_)); |
| 87 DCHECK(!sync_status_->IsWriting(url_)); | 88 DCHECK(!sync_status_->IsWriting(url_)); |
| 88 | 89 |
| 89 // Reopening the filesystem. | 90 // Reopening the filesystem. |
| 90 file_system_context_->sandbox_delegate()->OpenFileSystem( | 91 file_system_context_->sandbox_delegate()->OpenFileSystem( |
| 91 url_.origin(), | 92 url_.origin(), |
| 92 url_.type(), | 93 url_.type(), |
| 93 storage::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, | 94 storage::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, |
| 94 base::Bind(&RootDeleteHelper::DidOpenFileSystem, | 95 base::Bind(&RootDeleteHelper::DidOpenFileSystem, |
| 95 weak_factory_.GetWeakPtr()), | 96 weak_factory_.GetWeakPtr()), |
| 96 GURL()); | 97 GURL()); |
| 97 } | 98 } |
| 98 | 99 |
| 99 void RootDeleteHelper::DidOpenFileSystem(const GURL& /* root */, | 100 void RootDeleteHelper::DidOpenFileSystem(const GURL& /* root */, |
| 100 const std::string& /* name */, | 101 const std::string& /* name */, |
| 101 base::File::Error error) { | 102 base::File::Error error) { |
| 102 FileStatusCallback callback = callback_; | 103 FileStatusCallback callback = callback_; |
| 103 callback.Run(error); | 104 callback.Run(error); |
| 104 } | 105 } |
| 105 | 106 |
| 106 } // namespace sync_file_system | 107 } // namespace sync_file_system |
| OLD | NEW |