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

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

Issue 1036723003: favor DCHECK_CURRENTLY_ON for better logs in chrome/browser/chromeos/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
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/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"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
80 void TruncateOperation::Truncate(const base::FilePath& file_path, 80 void TruncateOperation::Truncate(const base::FilePath& file_path,
81 int64 length, 81 int64 length,
82 const FileOperationCallback& callback) { 82 const FileOperationCallback& callback) {
83 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 83 DCHECK_CURRENTLY_ON(BrowserThread::UI);
84 DCHECK(!callback.is_null()); 84 DCHECK(!callback.is_null());
85 85
86 if (length < 0) { 86 if (length < 0) {
87 base::MessageLoopProxy::current()->PostTask( 87 base::MessageLoopProxy::current()->PostTask(
88 FROM_HERE, 88 FROM_HERE,
89 base::Bind(callback, FILE_ERROR_INVALID_OPERATION)); 89 base::Bind(callback, FILE_ERROR_INVALID_OPERATION));
90 return; 90 return;
91 } 91 }
92 92
93 // TODO(kinaba): http://crbug.com/132780. 93 // TODO(kinaba): http://crbug.com/132780.
94 // Optimize the cases for small |length|, at least for |length| == 0. 94 // Optimize the cases for small |length|, at least for |length| == 0.
95 download_operation_->EnsureFileDownloadedByPath( 95 download_operation_->EnsureFileDownloadedByPath(
96 file_path, 96 file_path,
97 ClientContext(USER_INITIATED), 97 ClientContext(USER_INITIATED),
98 GetFileContentInitializedCallback(), 98 GetFileContentInitializedCallback(),
99 google_apis::GetContentCallback(), 99 google_apis::GetContentCallback(),
100 base::Bind(&TruncateOperation::TruncateAfterEnsureFileDownloadedByPath, 100 base::Bind(&TruncateOperation::TruncateAfterEnsureFileDownloadedByPath,
101 weak_ptr_factory_.GetWeakPtr(), length, callback)); 101 weak_ptr_factory_.GetWeakPtr(), length, callback));
102 } 102 }
103 103
104 void TruncateOperation::TruncateAfterEnsureFileDownloadedByPath( 104 void TruncateOperation::TruncateAfterEnsureFileDownloadedByPath(
105 int64 length, 105 int64 length,
106 const FileOperationCallback& callback, 106 const FileOperationCallback& callback,
107 FileError error, 107 FileError error,
108 const base::FilePath& local_file_path, 108 const base::FilePath& local_file_path,
109 scoped_ptr<ResourceEntry> entry) { 109 scoped_ptr<ResourceEntry> entry) {
110 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 110 DCHECK_CURRENTLY_ON(BrowserThread::UI);
111 DCHECK(!callback.is_null()); 111 DCHECK(!callback.is_null());
112 112
113 if (error != FILE_ERROR_OK) { 113 if (error != FILE_ERROR_OK) {
114 callback.Run(error); 114 callback.Run(error);
115 return; 115 return;
116 } 116 }
117 DCHECK(entry); 117 DCHECK(entry);
118 DCHECK(entry->has_file_specific_info()); 118 DCHECK(entry->has_file_specific_info());
119 119
120 if (entry->file_specific_info().is_hosted_document()) { 120 if (entry->file_specific_info().is_hosted_document()) {
121 callback.Run(FILE_ERROR_INVALID_OPERATION); 121 callback.Run(FILE_ERROR_INVALID_OPERATION);
122 return; 122 return;
123 } 123 }
124 124
125 base::PostTaskAndReplyWithResult( 125 base::PostTaskAndReplyWithResult(
126 blocking_task_runner_.get(), 126 blocking_task_runner_.get(),
127 FROM_HERE, 127 FROM_HERE,
128 base::Bind(&TruncateOnBlockingPool, 128 base::Bind(&TruncateOnBlockingPool,
129 metadata_, cache_, entry->local_id(), local_file_path, length), 129 metadata_, cache_, entry->local_id(), local_file_path, length),
130 base::Bind( 130 base::Bind(
131 &TruncateOperation::TruncateAfterTruncateOnBlockingPool, 131 &TruncateOperation::TruncateAfterTruncateOnBlockingPool,
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_CURRENTLY_ON(BrowserThread::UI);
140 DCHECK(!callback.is_null()); 140 DCHECK(!callback.is_null());
141 141
142 delegate_->OnEntryUpdatedByOperation(ClientContext(USER_INITIATED), local_id); 142 delegate_->OnEntryUpdatedByOperation(ClientContext(USER_INITIATED), 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
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/file_system/touch_operation.cc ('k') | chrome/browser/chromeos/drive/file_system_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698