Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1012)

Side by Side Diff: chrome/browser/chromeos/drive/file_system/copy_operation.cc

Issue 14493009: drive: Rename DriveScheduler to JobScheduler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix indent Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/copy_operation.h" 5 #include "chrome/browser/chromeos/drive/file_system/copy_operation.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/json/json_file_value_serializer.h" 10 #include "base/json/json_file_value_serializer.h"
11 #include "chrome/browser/chromeos/drive/drive.pb.h" 11 #include "chrome/browser/chromeos/drive/drive.pb.h"
12 #include "chrome/browser/chromeos/drive/drive_cache.h" 12 #include "chrome/browser/chromeos/drive/drive_cache.h"
13 #include "chrome/browser/chromeos/drive/drive_file_system_interface.h" 13 #include "chrome/browser/chromeos/drive/drive_file_system_interface.h"
14 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" 14 #include "chrome/browser/chromeos/drive/drive_file_system_util.h"
15 #include "chrome/browser/chromeos/drive/drive_scheduler.h"
16 #include "chrome/browser/chromeos/drive/file_system/move_operation.h" 15 #include "chrome/browser/chromeos/drive/file_system/move_operation.h"
17 #include "chrome/browser/chromeos/drive/file_system/operation_observer.h" 16 #include "chrome/browser/chromeos/drive/file_system/operation_observer.h"
17 #include "chrome/browser/chromeos/drive/job_scheduler.h"
18 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" 18 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h"
19 #include "chrome/browser/google_apis/drive_upload_error.h" 19 #include "chrome/browser/google_apis/drive_upload_error.h"
20 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
21 #include "net/base/mime_util.h" 21 #include "net/base/mime_util.h"
22 22
23 using content::BrowserThread; 23 using content::BrowserThread;
24 using google_apis::ResourceEntry; 24 using google_apis::ResourceEntry;
25 using google_apis::GDataErrorCode; 25 using google_apis::GDataErrorCode;
26 26
27 namespace drive { 27 namespace drive {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 : local_file_path(in_local_file_path), 68 : local_file_path(in_local_file_path),
69 remote_file_path(in_remote_file_path), 69 remote_file_path(in_remote_file_path),
70 callback(in_callback) {} 70 callback(in_callback) {}
71 71
72 const base::FilePath local_file_path; 72 const base::FilePath local_file_path;
73 const base::FilePath remote_file_path; 73 const base::FilePath remote_file_path;
74 const FileOperationCallback callback; 74 const FileOperationCallback callback;
75 }; 75 };
76 76
77 CopyOperation::CopyOperation( 77 CopyOperation::CopyOperation(
78 DriveScheduler* drive_scheduler, 78 JobScheduler* job_scheduler,
79 DriveFileSystemInterface* drive_file_system, 79 DriveFileSystemInterface* drive_file_system,
80 DriveResourceMetadata* metadata, 80 DriveResourceMetadata* metadata,
81 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, 81 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner,
82 OperationObserver* observer) 82 OperationObserver* observer)
83 : drive_scheduler_(drive_scheduler), 83 : job_scheduler_(job_scheduler),
84 drive_file_system_(drive_file_system), 84 drive_file_system_(drive_file_system),
85 metadata_(metadata), 85 metadata_(metadata),
86 blocking_task_runner_(blocking_task_runner), 86 blocking_task_runner_(blocking_task_runner),
87 observer_(observer), 87 observer_(observer),
88 move_operation_(new MoveOperation(drive_scheduler, 88 move_operation_(new MoveOperation(job_scheduler,
89 metadata, 89 metadata,
90 observer)), 90 observer)),
91 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 91 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
92 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 92 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
93 } 93 }
94 94
95 CopyOperation::~CopyOperation() { 95 CopyOperation::~CopyOperation() {
96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
97 } 97 }
98 98
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 } 194 }
195 195
196 void CopyOperation::CopyHostedDocumentToDirectory( 196 void CopyOperation::CopyHostedDocumentToDirectory(
197 const base::FilePath& dir_path, 197 const base::FilePath& dir_path,
198 const std::string& resource_id, 198 const std::string& resource_id,
199 const base::FilePath::StringType& new_name, 199 const base::FilePath::StringType& new_name,
200 const FileOperationCallback& callback) { 200 const FileOperationCallback& callback) {
201 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 201 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
202 DCHECK(!callback.is_null()); 202 DCHECK(!callback.is_null());
203 203
204 drive_scheduler_->CopyHostedDocument( 204 job_scheduler_->CopyHostedDocument(
205 resource_id, 205 resource_id,
206 base::FilePath(new_name).AsUTF8Unsafe(), 206 base::FilePath(new_name).AsUTF8Unsafe(),
207 base::Bind(&CopyOperation::OnCopyHostedDocumentCompleted, 207 base::Bind(&CopyOperation::OnCopyHostedDocumentCompleted,
208 weak_ptr_factory_.GetWeakPtr(), 208 weak_ptr_factory_.GetWeakPtr(),
209 dir_path, 209 dir_path,
210 callback)); 210 callback));
211 } 211 }
212 212
213 void CopyOperation::OnCopyHostedDocumentCompleted( 213 void CopyOperation::OnCopyHostedDocumentCompleted(
214 const base::FilePath& dir_path, 214 const base::FilePath& dir_path,
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 352
353 if (entry_proto.get() && !entry_proto->file_info().is_directory()) 353 if (entry_proto.get() && !entry_proto->file_info().is_directory())
354 error = FILE_ERROR_NOT_A_DIRECTORY; 354 error = FILE_ERROR_NOT_A_DIRECTORY;
355 355
356 if (error != FILE_ERROR_OK) { 356 if (error != FILE_ERROR_OK) {
357 params.callback.Run(error); 357 params.callback.Run(error);
358 return; 358 return;
359 } 359 }
360 DCHECK(entry_proto.get()); 360 DCHECK(entry_proto.get());
361 361
362 drive_scheduler_->UploadNewFile( 362 job_scheduler_->UploadNewFile(
363 entry_proto->resource_id(), 363 entry_proto->resource_id(),
364 params.remote_file_path, 364 params.remote_file_path,
365 params.local_file_path, 365 params.local_file_path,
366 params.remote_file_path.BaseName().value(), 366 params.remote_file_path.BaseName().value(),
367 content_type, 367 content_type,
368 DriveClientContext(USER_INITIATED), 368 DriveClientContext(USER_INITIATED),
369 base::Bind(&CopyOperation::OnTransferCompleted, 369 base::Bind(&CopyOperation::OnTransferCompleted,
370 weak_ptr_factory_.GetWeakPtr(), 370 weak_ptr_factory_.GetWeakPtr(),
371 params.callback)); 371 params.callback));
372 } 372 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 remote_dest_file_path.DirName(), 441 remote_dest_file_path.DirName(),
442 resource_id, 442 resource_id,
443 // Drop the document extension, which should not be 443 // Drop the document extension, which should not be
444 // in the document title. 444 // in the document title.
445 remote_dest_file_path.BaseName().RemoveExtension().value(), 445 remote_dest_file_path.BaseName().RemoveExtension().value(),
446 callback); 446 callback);
447 } 447 }
448 448
449 } // namespace file_system 449 } // namespace file_system
450 } // namespace drive 450 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698