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 "chrome/browser/chromeos/drive/file_system/move_operation.h" | 5 #include "chrome/browser/chromeos/drive/file_system/move_operation.h" |
6 | 6 |
7 #include "base/sequenced_task_runner.h" | 7 #include "base/sequenced_task_runner.h" |
8 #include "chrome/browser/chromeos/drive/drive.pb.h" | 8 #include "chrome/browser/chromeos/drive/drive.pb.h" |
9 #include "chrome/browser/chromeos/drive/file_change.h" | 9 #include "chrome/browser/chromeos/drive/file_change.h" |
10 #include "chrome/browser/chromeos/drive/file_system/operation_delegate.h" | 10 #include "chrome/browser/chromeos/drive/file_system/operation_delegate.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 67 |
68 } // namespace | 68 } // namespace |
69 | 69 |
70 MoveOperation::MoveOperation(base::SequencedTaskRunner* blocking_task_runner, | 70 MoveOperation::MoveOperation(base::SequencedTaskRunner* blocking_task_runner, |
71 OperationDelegate* delegate, | 71 OperationDelegate* delegate, |
72 internal::ResourceMetadata* metadata) | 72 internal::ResourceMetadata* metadata) |
73 : blocking_task_runner_(blocking_task_runner), | 73 : blocking_task_runner_(blocking_task_runner), |
74 delegate_(delegate), | 74 delegate_(delegate), |
75 metadata_(metadata), | 75 metadata_(metadata), |
76 weak_ptr_factory_(this) { | 76 weak_ptr_factory_(this) { |
77 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 77 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
78 } | 78 } |
79 | 79 |
80 MoveOperation::~MoveOperation() { | 80 MoveOperation::~MoveOperation() { |
81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 81 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
82 } | 82 } |
83 | 83 |
84 void MoveOperation::Move(const base::FilePath& src_file_path, | 84 void MoveOperation::Move(const base::FilePath& src_file_path, |
85 const base::FilePath& dest_file_path, | 85 const base::FilePath& dest_file_path, |
86 const FileOperationCallback& callback) { | 86 const FileOperationCallback& callback) { |
87 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 87 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
88 DCHECK(!callback.is_null()); | 88 DCHECK(!callback.is_null()); |
89 | 89 |
90 FileChange* changed_files = new FileChange; | 90 FileChange* changed_files = new FileChange; |
91 std::string* local_id = new std::string; | 91 std::string* local_id = new std::string; |
92 base::PostTaskAndReplyWithResult( | 92 base::PostTaskAndReplyWithResult( |
93 blocking_task_runner_.get(), | 93 blocking_task_runner_.get(), |
94 FROM_HERE, | 94 FROM_HERE, |
95 base::Bind(&UpdateLocalState, | 95 base::Bind(&UpdateLocalState, |
96 metadata_, | 96 metadata_, |
97 src_file_path, | 97 src_file_path, |
98 dest_file_path, | 98 dest_file_path, |
99 changed_files, | 99 changed_files, |
100 local_id), | 100 local_id), |
101 base::Bind(&MoveOperation::MoveAfterUpdateLocalState, | 101 base::Bind(&MoveOperation::MoveAfterUpdateLocalState, |
102 weak_ptr_factory_.GetWeakPtr(), | 102 weak_ptr_factory_.GetWeakPtr(), |
103 callback, | 103 callback, |
104 base::Owned(changed_files), | 104 base::Owned(changed_files), |
105 base::Owned(local_id))); | 105 base::Owned(local_id))); |
106 } | 106 } |
107 | 107 |
108 void MoveOperation::MoveAfterUpdateLocalState( | 108 void MoveOperation::MoveAfterUpdateLocalState( |
109 const FileOperationCallback& callback, | 109 const FileOperationCallback& callback, |
110 const FileChange* changed_files, | 110 const FileChange* changed_files, |
111 const std::string* local_id, | 111 const std::string* local_id, |
112 FileError error) { | 112 FileError error) { |
113 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 113 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
114 if (error == FILE_ERROR_OK) { | 114 if (error == FILE_ERROR_OK) { |
115 // Notify the change of directory. | 115 // Notify the change of directory. |
116 delegate_->OnFileChangedByOperation(*changed_files); | 116 delegate_->OnFileChangedByOperation(*changed_files); |
117 delegate_->OnEntryUpdatedByOperation(ClientContext(USER_INITIATED), | 117 delegate_->OnEntryUpdatedByOperation(ClientContext(USER_INITIATED), |
118 *local_id); | 118 *local_id); |
119 } | 119 } |
120 callback.Run(error); | 120 callback.Run(error); |
121 } | 121 } |
122 | 122 |
123 } // namespace file_system | 123 } // namespace file_system |
124 } // namespace drive | 124 } // namespace drive |
OLD | NEW |