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/remove_operation.h" | 5 #include "chrome/browser/chromeos/drive/file_system/remove_operation.h" |
6 | 6 |
7 #include "chrome/browser/chromeos/drive/drive.pb.h" | 7 #include "chrome/browser/chromeos/drive/drive.pb.h" |
8 #include "chrome/browser/chromeos/drive/drive_cache.h" | 8 #include "chrome/browser/chromeos/drive/drive_cache.h" |
9 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" | 9 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" |
10 #include "chrome/browser/chromeos/drive/drive_scheduler.h" | |
11 #include "chrome/browser/chromeos/drive/file_system/operation_observer.h" | 10 #include "chrome/browser/chromeos/drive/file_system/operation_observer.h" |
| 11 #include "chrome/browser/chromeos/drive/job_scheduler.h" |
12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
13 | 13 |
14 using content::BrowserThread; | 14 using content::BrowserThread; |
15 | 15 |
16 namespace drive { | 16 namespace drive { |
17 namespace file_system { | 17 namespace file_system { |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 void EmptyFileOperationCallback(FileError error) {} | 21 void EmptyFileOperationCallback(FileError error) {} |
22 | 22 |
23 } // namespace | 23 } // namespace |
24 | 24 |
25 RemoveOperation::RemoveOperation( | 25 RemoveOperation::RemoveOperation( |
26 DriveScheduler* drive_scheduler, | 26 JobScheduler* job_scheduler, |
27 DriveCache* cache, | 27 DriveCache* cache, |
28 DriveResourceMetadata* metadata, | 28 DriveResourceMetadata* metadata, |
29 OperationObserver* observer) | 29 OperationObserver* observer) |
30 : drive_scheduler_(drive_scheduler), | 30 : job_scheduler_(job_scheduler), |
31 cache_(cache), | 31 cache_(cache), |
32 metadata_(metadata), | 32 metadata_(metadata), |
33 observer_(observer), | 33 observer_(observer), |
34 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 34 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
36 } | 36 } |
37 | 37 |
38 RemoveOperation::~RemoveOperation() { | 38 RemoveOperation::~RemoveOperation() { |
39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
40 } | 40 } |
(...skipping 20 matching lines...) Expand all Loading... |
61 scoped_ptr<DriveEntryProto> entry_proto) { | 61 scoped_ptr<DriveEntryProto> entry_proto) { |
62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
63 DCHECK(!callback.is_null()); | 63 DCHECK(!callback.is_null()); |
64 | 64 |
65 if (error != FILE_ERROR_OK) { | 65 if (error != FILE_ERROR_OK) { |
66 callback.Run(error); | 66 callback.Run(error); |
67 return; | 67 return; |
68 } | 68 } |
69 DCHECK(entry_proto.get()); | 69 DCHECK(entry_proto.get()); |
70 | 70 |
71 drive_scheduler_->DeleteResource( | 71 job_scheduler_->DeleteResource( |
72 entry_proto->resource_id(), | 72 entry_proto->resource_id(), |
73 base::Bind(&RemoveOperation::RemoveResourceLocally, | 73 base::Bind(&RemoveOperation::RemoveResourceLocally, |
74 weak_ptr_factory_.GetWeakPtr(), | 74 weak_ptr_factory_.GetWeakPtr(), |
75 callback, | 75 callback, |
76 entry_proto->resource_id())); | 76 entry_proto->resource_id())); |
77 } | 77 } |
78 | 78 |
79 void RemoveOperation::RemoveResourceLocally( | 79 void RemoveOperation::RemoveResourceLocally( |
80 const FileOperationCallback& callback, | 80 const FileOperationCallback& callback, |
81 const std::string& resource_id, | 81 const std::string& resource_id, |
(...skipping 23 matching lines...) Expand all Loading... |
105 DCHECK(!callback.is_null()); | 105 DCHECK(!callback.is_null()); |
106 | 106 |
107 if (error == FILE_ERROR_OK) | 107 if (error == FILE_ERROR_OK) |
108 observer_->OnDirectoryChangedByOperation(directory_path); | 108 observer_->OnDirectoryChangedByOperation(directory_path); |
109 | 109 |
110 callback.Run(error); | 110 callback.Run(error); |
111 } | 111 } |
112 | 112 |
113 } // namespace file_system | 113 } // namespace file_system |
114 } // namespace drive | 114 } // namespace drive |
OLD | NEW |