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

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

Issue 408143014: Rename OperationObserver to OperationDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 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/create_file_operation.h" 5 #include "chrome/browser/chromeos/drive/file_system/create_file_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 "chrome/browser/chromeos/drive/drive.pb.h" 10 #include "chrome/browser/chromeos/drive/drive.pb.h"
11 #include "chrome/browser/chromeos/drive/file_change.h" 11 #include "chrome/browser/chromeos/drive/file_change.h"
12 #include "chrome/browser/chromeos/drive/file_system/operation_observer.h" 12 #include "chrome/browser/chromeos/drive/file_system/operation_delegate.h"
13 #include "chrome/browser/chromeos/drive/resource_metadata.h" 13 #include "chrome/browser/chromeos/drive/resource_metadata.h"
14 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
15 #include "net/base/mime_util.h" 15 #include "net/base/mime_util.h"
16 16
17 using content::BrowserThread; 17 using content::BrowserThread;
18 18
19 namespace drive { 19 namespace drive {
20 namespace file_system { 20 namespace file_system {
21 21
22 namespace { 22 namespace {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 std::string local_id; 64 std::string local_id;
65 error = metadata->AddEntry(*entry, &local_id); 65 error = metadata->AddEntry(*entry, &local_id);
66 entry->set_local_id(local_id); 66 entry->set_local_id(local_id);
67 return error; 67 return error;
68 } 68 }
69 69
70 } // namespace 70 } // namespace
71 71
72 CreateFileOperation::CreateFileOperation( 72 CreateFileOperation::CreateFileOperation(
73 base::SequencedTaskRunner* blocking_task_runner, 73 base::SequencedTaskRunner* blocking_task_runner,
74 OperationObserver* observer, 74 OperationDelegate* delegate,
75 internal::ResourceMetadata* metadata) 75 internal::ResourceMetadata* metadata)
76 : blocking_task_runner_(blocking_task_runner), 76 : blocking_task_runner_(blocking_task_runner),
77 observer_(observer), 77 delegate_(delegate),
78 metadata_(metadata), 78 metadata_(metadata),
79 weak_ptr_factory_(this) { 79 weak_ptr_factory_(this) {
80 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 80 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
81 } 81 }
82 82
83 CreateFileOperation::~CreateFileOperation() { 83 CreateFileOperation::~CreateFileOperation() {
84 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 84 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
85 } 85 }
86 86
87 void CreateFileOperation::CreateFile(const base::FilePath& file_path, 87 void CreateFileOperation::CreateFile(const base::FilePath& file_path,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 119
120 if (error == FILE_ERROR_EXISTS) { 120 if (error == FILE_ERROR_EXISTS) {
121 // Error if an exclusive mode is requested, or the entry is not a file. 121 // Error if an exclusive mode is requested, or the entry is not a file.
122 error = (is_exclusive || 122 error = (is_exclusive ||
123 entry->file_info().is_directory() || 123 entry->file_info().is_directory() ||
124 entry->file_specific_info().is_hosted_document()) ? 124 entry->file_specific_info().is_hosted_document()) ?
125 FILE_ERROR_EXISTS : FILE_ERROR_OK; 125 FILE_ERROR_EXISTS : FILE_ERROR_OK;
126 } else if (error == FILE_ERROR_OK) { 126 } else if (error == FILE_ERROR_OK) {
127 DCHECK(!entry->file_info().is_directory()); 127 DCHECK(!entry->file_info().is_directory());
128 128
129 // Notify observer if the file was newly created. 129 // Notify delegate if the file was newly created.
130 FileChange changed_file; 130 FileChange changed_file;
131 changed_file.Update( 131 changed_file.Update(
132 file_path, FileChange::FILE_TYPE_FILE, FileChange::ADD_OR_UPDATE); 132 file_path, FileChange::FILE_TYPE_FILE, FileChange::ADD_OR_UPDATE);
133 observer_->OnFileChangedByOperation(changed_file); 133 delegate_->OnFileChangedByOperation(changed_file);
134 observer_->OnEntryUpdatedByOperation(entry->local_id()); 134 delegate_->OnEntryUpdatedByOperation(entry->local_id());
135 } 135 }
136 callback.Run(error); 136 callback.Run(error);
137 } 137 }
138 138
139 } // namespace file_system 139 } // namespace file_system
140 } // namespace drive 140 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698