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/truncate_operation.h" | 5 #include "chrome/browser/chromeos/drive/file_system/truncate_operation.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/message_loop/message_loop_proxy.h" | 12 #include "base/message_loop/message_loop_proxy.h" |
13 #include "base/sequenced_task_runner.h" | 13 #include "base/sequenced_task_runner.h" |
14 #include "base/task_runner_util.h" | 14 #include "base/task_runner_util.h" |
15 #include "chrome/browser/chromeos/drive/drive.pb.h" | 15 #include "chrome/browser/chromeos/drive/drive.pb.h" |
16 #include "chrome/browser/chromeos/drive/file_cache.h" | 16 #include "chrome/browser/chromeos/drive/file_cache.h" |
17 #include "chrome/browser/chromeos/drive/file_errors.h" | 17 #include "chrome/browser/chromeos/drive/file_errors.h" |
18 #include "chrome/browser/chromeos/drive/file_system/download_operation.h" | 18 #include "chrome/browser/chromeos/drive/file_system/download_operation.h" |
19 #include "chrome/browser/chromeos/drive/file_system/operation_observer.h" | 19 #include "chrome/browser/chromeos/drive/file_system/operation_delegate.h" |
20 #include "chrome/browser/chromeos/drive/job_scheduler.h" | 20 #include "chrome/browser/chromeos/drive/job_scheduler.h" |
21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
22 | 22 |
23 using content::BrowserThread; | 23 using content::BrowserThread; |
24 | 24 |
25 namespace drive { | 25 namespace drive { |
26 namespace file_system { | 26 namespace file_system { |
27 namespace { | 27 namespace { |
28 | 28 |
29 // Truncates the local file at |local_cache_path| to the |length| bytes, | 29 // Truncates the local file at |local_cache_path| to the |length| bytes, |
(...skipping 19 matching lines...) Expand all Loading... |
49 if (!file.SetLength(length)) | 49 if (!file.SetLength(length)) |
50 return FILE_ERROR_FAILED; | 50 return FILE_ERROR_FAILED; |
51 | 51 |
52 return FILE_ERROR_OK; | 52 return FILE_ERROR_OK; |
53 } | 53 } |
54 | 54 |
55 } // namespace | 55 } // namespace |
56 | 56 |
57 TruncateOperation::TruncateOperation( | 57 TruncateOperation::TruncateOperation( |
58 base::SequencedTaskRunner* blocking_task_runner, | 58 base::SequencedTaskRunner* blocking_task_runner, |
59 OperationObserver* observer, | 59 OperationDelegate* delegate, |
60 JobScheduler* scheduler, | 60 JobScheduler* scheduler, |
61 internal::ResourceMetadata* metadata, | 61 internal::ResourceMetadata* metadata, |
62 internal::FileCache* cache, | 62 internal::FileCache* cache, |
63 const base::FilePath& temporary_file_directory) | 63 const base::FilePath& temporary_file_directory) |
64 : blocking_task_runner_(blocking_task_runner), | 64 : blocking_task_runner_(blocking_task_runner), |
65 observer_(observer), | 65 delegate_(delegate), |
66 metadata_(metadata), | 66 metadata_(metadata), |
67 cache_(cache), | 67 cache_(cache), |
68 download_operation_(new DownloadOperation(blocking_task_runner, | 68 download_operation_(new DownloadOperation(blocking_task_runner, |
69 observer, | 69 delegate, |
70 scheduler, | 70 scheduler, |
71 metadata, | 71 metadata, |
72 cache, | 72 cache, |
73 temporary_file_directory)), | 73 temporary_file_directory)), |
74 weak_ptr_factory_(this) { | 74 weak_ptr_factory_(this) { |
75 } | 75 } |
76 | 76 |
77 TruncateOperation::~TruncateOperation() { | 77 TruncateOperation::~TruncateOperation() { |
78 } | 78 } |
79 | 79 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 weak_ptr_factory_.GetWeakPtr(), entry->local_id(), callback)); | 132 weak_ptr_factory_.GetWeakPtr(), entry->local_id(), callback)); |
133 } | 133 } |
134 | 134 |
135 void TruncateOperation::TruncateAfterTruncateOnBlockingPool( | 135 void TruncateOperation::TruncateAfterTruncateOnBlockingPool( |
136 const std::string& local_id, | 136 const std::string& local_id, |
137 const FileOperationCallback& callback, | 137 const FileOperationCallback& callback, |
138 FileError error) { | 138 FileError error) { |
139 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 139 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
140 DCHECK(!callback.is_null()); | 140 DCHECK(!callback.is_null()); |
141 | 141 |
142 observer_->OnEntryUpdatedByOperation(local_id); | 142 delegate_->OnEntryUpdatedByOperation(local_id); |
143 | 143 |
144 callback.Run(error); | 144 callback.Run(error); |
145 } | 145 } |
146 | 146 |
147 } // namespace file_system | 147 } // namespace file_system |
148 } // namespace drive | 148 } // namespace drive |
OLD | NEW |