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/chromeos/drive/file_system/touch_operation.h" | 5 #include "chrome/browser/chromeos/drive/file_system/touch_operation.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/sequenced_task_runner.h" | 9 #include "base/sequenced_task_runner.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 weak_ptr_factory_(this) { | 53 weak_ptr_factory_(this) { |
54 } | 54 } |
55 | 55 |
56 TouchOperation::~TouchOperation() { | 56 TouchOperation::~TouchOperation() { |
57 } | 57 } |
58 | 58 |
59 void TouchOperation::TouchFile(const base::FilePath& file_path, | 59 void TouchOperation::TouchFile(const base::FilePath& file_path, |
60 const base::Time& last_access_time, | 60 const base::Time& last_access_time, |
61 const base::Time& last_modified_time, | 61 const base::Time& last_modified_time, |
62 const FileOperationCallback& callback) { | 62 const FileOperationCallback& callback) { |
63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 63 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
64 DCHECK(!callback.is_null()); | 64 DCHECK(!callback.is_null()); |
65 | 65 |
66 ResourceEntry* entry = new ResourceEntry; | 66 ResourceEntry* entry = new ResourceEntry; |
67 base::PostTaskAndReplyWithResult( | 67 base::PostTaskAndReplyWithResult( |
68 blocking_task_runner_.get(), FROM_HERE, | 68 blocking_task_runner_.get(), FROM_HERE, |
69 base::Bind(&UpdateLocalState, metadata_, file_path, last_access_time, | 69 base::Bind(&UpdateLocalState, metadata_, file_path, last_access_time, |
70 last_modified_time, entry), | 70 last_modified_time, entry), |
71 base::Bind(&TouchOperation::TouchFileAfterUpdateLocalState, | 71 base::Bind(&TouchOperation::TouchFileAfterUpdateLocalState, |
72 weak_ptr_factory_.GetWeakPtr(), file_path, callback, | 72 weak_ptr_factory_.GetWeakPtr(), file_path, callback, |
73 base::Owned(entry))); | 73 base::Owned(entry))); |
74 } | 74 } |
75 | 75 |
76 void TouchOperation::TouchFileAfterUpdateLocalState( | 76 void TouchOperation::TouchFileAfterUpdateLocalState( |
77 const base::FilePath& file_path, | 77 const base::FilePath& file_path, |
78 const FileOperationCallback& callback, | 78 const FileOperationCallback& callback, |
79 const ResourceEntry* entry, | 79 const ResourceEntry* entry, |
80 FileError error) { | 80 FileError error) { |
81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 81 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
82 DCHECK(!callback.is_null()); | 82 DCHECK(!callback.is_null()); |
83 | 83 |
84 FileChange changed_files; | 84 FileChange changed_files; |
85 changed_files.Update( | 85 changed_files.Update( |
86 file_path, | 86 file_path, |
87 entry->file_info().is_directory() ? | 87 entry->file_info().is_directory() ? |
88 FileChange::FILE_TYPE_DIRECTORY : FileChange::FILE_TYPE_FILE, | 88 FileChange::FILE_TYPE_DIRECTORY : FileChange::FILE_TYPE_FILE, |
89 FileChange::ADD_OR_UPDATE); | 89 FileChange::ADD_OR_UPDATE); |
90 | 90 |
91 if (error == FILE_ERROR_OK) { | 91 if (error == FILE_ERROR_OK) { |
92 delegate_->OnFileChangedByOperation(changed_files); | 92 delegate_->OnFileChangedByOperation(changed_files); |
93 delegate_->OnEntryUpdatedByOperation(ClientContext(USER_INITIATED), | 93 delegate_->OnEntryUpdatedByOperation(ClientContext(USER_INITIATED), |
94 entry->local_id()); | 94 entry->local_id()); |
95 } | 95 } |
96 callback.Run(error); | 96 callback.Run(error); |
97 } | 97 } |
98 | 98 |
99 } // namespace file_system | 99 } // namespace file_system |
100 } // namespace drive | 100 } // namespace drive |
OLD | NEW |