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

Side by Side Diff: net/base/file_stream_context.cc

Issue 1545233002: Convert Pass()→std::move() in //net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
« no previous file with comments | « net/base/file_stream.cc ('k') | net/base/file_stream_context_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "net/base/file_stream_context.h" 5 #include "net/base/file_stream_context.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 return IOResult(MapSystemError(os_error), os_error); 45 return IOResult(MapSystemError(os_error), os_error);
46 } 46 }
47 47
48 // --------------------------------------------------------------------- 48 // ---------------------------------------------------------------------
49 49
50 FileStream::Context::OpenResult::OpenResult() { 50 FileStream::Context::OpenResult::OpenResult() {
51 } 51 }
52 52
53 FileStream::Context::OpenResult::OpenResult(base::File file, 53 FileStream::Context::OpenResult::OpenResult(base::File file,
54 IOResult error_code) 54 IOResult error_code)
55 : file(file.Pass()), 55 : file(std::move(file)), error_code(error_code) {}
56 error_code(error_code) {
57 }
58 56
59 FileStream::Context::OpenResult::OpenResult(OpenResult&& other) 57 FileStream::Context::OpenResult::OpenResult(OpenResult&& other)
60 : file(std::move(other.file)), error_code(other.error_code) {} 58 : file(std::move(other.file)), error_code(other.error_code) {}
61 59
62 FileStream::Context::OpenResult& FileStream::Context::OpenResult::operator=( 60 FileStream::Context::OpenResult& FileStream::Context::OpenResult::operator=(
63 OpenResult&& other) { 61 OpenResult&& other) {
64 file = std::move(other.file); 62 file = std::move(other.file);
65 error_code = other.error_code; 63 error_code = other.error_code;
66 return *this; 64 return *this;
67 } 65 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 // presumably happen on the wrong thread. There should be an async delete. 165 // presumably happen on the wrong thread. There should be an async delete.
168 open_flags |= base::File::FLAG_SHARE_DELETE; 166 open_flags |= base::File::FLAG_SHARE_DELETE;
169 file.Initialize(path, open_flags); 167 file.Initialize(path, open_flags);
170 #if defined(OS_ANDROID) 168 #if defined(OS_ANDROID)
171 } 169 }
172 #endif // defined(OS_ANDROID) 170 #endif // defined(OS_ANDROID)
173 if (!file.IsValid()) 171 if (!file.IsValid())
174 return OpenResult(base::File(), 172 return OpenResult(base::File(),
175 IOResult::FromOSError(logging::GetLastSystemErrorCode())); 173 IOResult::FromOSError(logging::GetLastSystemErrorCode()));
176 174
177 return OpenResult(file.Pass(), IOResult(OK, 0)); 175 return OpenResult(std::move(file), IOResult(OK, 0));
178 } 176 }
179 177
180 FileStream::Context::IOResult FileStream::Context::CloseFileImpl() { 178 FileStream::Context::IOResult FileStream::Context::CloseFileImpl() {
181 file_.Close(); 179 file_.Close();
182 return IOResult(OK, 0); 180 return IOResult(OK, 0);
183 } 181 }
184 182
185 FileStream::Context::IOResult FileStream::Context::FlushFileImpl() { 183 FileStream::Context::IOResult FileStream::Context::FlushFileImpl() {
186 if (file_.Flush()) 184 if (file_.Flush())
187 return IOResult(OK, 0); 185 return IOResult(OK, 0);
188 186
189 return IOResult::FromOSError(logging::GetLastSystemErrorCode()); 187 return IOResult::FromOSError(logging::GetLastSystemErrorCode());
190 } 188 }
191 189
192 void FileStream::Context::OnOpenCompleted(const CompletionCallback& callback, 190 void FileStream::Context::OnOpenCompleted(const CompletionCallback& callback,
193 OpenResult open_result) { 191 OpenResult open_result) {
194 file_ = open_result.file.Pass(); 192 file_ = std::move(open_result.file);
195 if (file_.IsValid() && !orphaned_) 193 if (file_.IsValid() && !orphaned_)
196 OnFileOpened(); 194 OnFileOpened();
197 195
198 OnAsyncCompleted(IntToInt64(callback), open_result.error_code); 196 OnAsyncCompleted(IntToInt64(callback), open_result.error_code);
199 } 197 }
200 198
201 void FileStream::Context::CloseAndDelete() { 199 void FileStream::Context::CloseAndDelete() {
202 // TODO(ananta) 200 // TODO(ananta)
203 // Replace this CHECK with a DCHECK once we figure out the root cause of 201 // Replace this CHECK with a DCHECK once we figure out the root cause of
204 // http://crbug.com/455066 202 // http://crbug.com/455066
(...skipping 26 matching lines...) Expand all
231 // should be reset before Close() because it shouldn't run if any async 229 // should be reset before Close() because it shouldn't run if any async
232 // operation is in progress. 230 // operation is in progress.
233 async_in_progress_ = false; 231 async_in_progress_ = false;
234 if (orphaned_) 232 if (orphaned_)
235 CloseAndDelete(); 233 CloseAndDelete();
236 else 234 else
237 callback.Run(result.result); 235 callback.Run(result.result);
238 } 236 }
239 237
240 } // namespace net 238 } // namespace net
OLDNEW
« no previous file with comments | « net/base/file_stream.cc ('k') | net/base/file_stream_context_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698