OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/create_directory_operation.h
" | 5 #include "chrome/browser/chromeos/drive/file_system/create_directory_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_file_system_util.h" | 8 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" |
9 #include "chrome/browser/chromeos/drive/drive_scheduler.h" | |
10 #include "chrome/browser/chromeos/drive/file_system/operation_observer.h" | 9 #include "chrome/browser/chromeos/drive/file_system/operation_observer.h" |
| 10 #include "chrome/browser/chromeos/drive/job_scheduler.h" |
11 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" | 11 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" |
12 #include "chrome/browser/google_apis/gdata_errorcode.h" | 12 #include "chrome/browser/google_apis/gdata_errorcode.h" |
13 #include "chrome/browser/google_apis/gdata_wapi_parser.h" | 13 #include "chrome/browser/google_apis/gdata_wapi_parser.h" |
14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
15 | 15 |
16 using content::BrowserThread; | 16 using content::BrowserThread; |
17 | 17 |
18 namespace drive { | 18 namespace drive { |
19 namespace file_system { | 19 namespace file_system { |
20 | 20 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 ~FindFirstMissingParentDirectoryParams() {} | 67 ~FindFirstMissingParentDirectoryParams() {} |
68 | 68 |
69 std::vector<base::FilePath::StringType> path_parts; | 69 std::vector<base::FilePath::StringType> path_parts; |
70 size_t index; | 70 size_t index; |
71 base::FilePath current_path; | 71 base::FilePath current_path; |
72 std::string last_dir_resource_id; | 72 std::string last_dir_resource_id; |
73 const FindFirstMissingParentDirectoryCallback callback; | 73 const FindFirstMissingParentDirectoryCallback callback; |
74 }; | 74 }; |
75 | 75 |
76 CreateDirectoryOperation::CreateDirectoryOperation( | 76 CreateDirectoryOperation::CreateDirectoryOperation( |
77 DriveScheduler* drive_scheduler, | 77 JobScheduler* job_scheduler, |
78 DriveResourceMetadata* metadata, | 78 DriveResourceMetadata* metadata, |
79 OperationObserver* observer) | 79 OperationObserver* observer) |
80 : drive_scheduler_(drive_scheduler), | 80 : job_scheduler_(job_scheduler), |
81 metadata_(metadata), | 81 metadata_(metadata), |
82 observer_(observer), | 82 observer_(observer), |
83 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 83 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
84 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 84 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
85 } | 85 } |
86 | 86 |
87 CreateDirectoryOperation::~CreateDirectoryOperation() { | 87 CreateDirectoryOperation::~CreateDirectoryOperation() { |
88 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 88 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
89 } | 89 } |
90 | 90 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 } | 135 } |
136 | 136 |
137 // Do we have a parent directory here as well? We can't then create target | 137 // Do we have a parent directory here as well? We can't then create target |
138 // directory if this is not a recursive operation. | 138 // directory if this is not a recursive operation. |
139 if (params->target_directory_path != result.first_missing_parent_path && | 139 if (params->target_directory_path != result.first_missing_parent_path && |
140 !params->is_recursive) { | 140 !params->is_recursive) { |
141 params->callback.Run(FILE_ERROR_NOT_FOUND); | 141 params->callback.Run(FILE_ERROR_NOT_FOUND); |
142 return; | 142 return; |
143 } | 143 } |
144 | 144 |
145 drive_scheduler_->AddNewDirectory( | 145 job_scheduler_->AddNewDirectory( |
146 result.last_dir_resource_id, | 146 result.last_dir_resource_id, |
147 result.first_missing_parent_path.BaseName().AsUTF8Unsafe(), | 147 result.first_missing_parent_path.BaseName().AsUTF8Unsafe(), |
148 base::Bind(&CreateDirectoryOperation::AddNewDirectory, | 148 base::Bind(&CreateDirectoryOperation::AddNewDirectory, |
149 weak_ptr_factory_.GetWeakPtr(), | 149 weak_ptr_factory_.GetWeakPtr(), |
150 base::Passed(¶ms), | 150 base::Passed(¶ms), |
151 result.first_missing_parent_path)); | 151 result.first_missing_parent_path)); |
152 } | 152 } |
153 | 153 |
154 void CreateDirectoryOperation::AddNewDirectory( | 154 void CreateDirectoryOperation::AddNewDirectory( |
155 scoped_ptr<CreateDirectoryParams> params, | 155 scoped_ptr<CreateDirectoryParams> params, |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 } else { | 270 } else { |
271 // This parent exists, so recursively look at the next element. | 271 // This parent exists, so recursively look at the next element. |
272 params->last_dir_resource_id = entry_proto->resource_id(); | 272 params->last_dir_resource_id = entry_proto->resource_id(); |
273 params->index++; | 273 params->index++; |
274 FindFirstMissingParentDirectoryInternal(params.Pass()); | 274 FindFirstMissingParentDirectoryInternal(params.Pass()); |
275 } | 275 } |
276 } | 276 } |
277 | 277 |
278 } // namespace file_system | 278 } // namespace file_system |
279 } // namespace drive | 279 } // namespace drive |
OLD | NEW |