OLD | NEW |
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> |
| 8 |
7 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
8 #include "base/location.h" | 10 #include "base/location.h" |
9 #include "base/profiler/scoped_tracker.h" | 11 #include "base/profiler/scoped_tracker.h" |
10 #include "base/task_runner.h" | 12 #include "base/task_runner.h" |
11 #include "base/task_runner_util.h" | 13 #include "base/task_runner_util.h" |
12 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.h" |
13 #include "base/values.h" | 15 #include "base/values.h" |
14 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
15 | 17 |
16 #if defined(OS_ANDROID) | 18 #if defined(OS_ANDROID) |
(...skipping 30 matching lines...) Expand all Loading... |
47 | 49 |
48 FileStream::Context::OpenResult::OpenResult() { | 50 FileStream::Context::OpenResult::OpenResult() { |
49 } | 51 } |
50 | 52 |
51 FileStream::Context::OpenResult::OpenResult(base::File file, | 53 FileStream::Context::OpenResult::OpenResult(base::File file, |
52 IOResult error_code) | 54 IOResult error_code) |
53 : file(file.Pass()), | 55 : file(file.Pass()), |
54 error_code(error_code) { | 56 error_code(error_code) { |
55 } | 57 } |
56 | 58 |
57 FileStream::Context::OpenResult::OpenResult(RValue other) | 59 FileStream::Context::OpenResult::OpenResult(OpenResult&& other) |
58 : file(other.object->file.Pass()), | 60 : file(std::move(other.file)), error_code(other.error_code) {} |
59 error_code(other.object->error_code) { | |
60 } | |
61 | 61 |
62 FileStream::Context::OpenResult& FileStream::Context::OpenResult::operator=( | 62 FileStream::Context::OpenResult& FileStream::Context::OpenResult::operator=( |
63 RValue other) { | 63 OpenResult&& other) { |
64 if (this != other.object) { | 64 file = std::move(other.file); |
65 file = other.object->file.Pass(); | 65 error_code = other.error_code; |
66 error_code = other.object->error_code; | |
67 } | |
68 return *this; | 66 return *this; |
69 } | 67 } |
70 | 68 |
71 // --------------------------------------------------------------------- | 69 // --------------------------------------------------------------------- |
72 | 70 |
73 void FileStream::Context::Orphan() { | 71 void FileStream::Context::Orphan() { |
74 DCHECK(!orphaned_); | 72 DCHECK(!orphaned_); |
75 | 73 |
76 orphaned_ = true; | 74 orphaned_ = true; |
77 | 75 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 // should be reset before Close() because it shouldn't run if any async | 231 // should be reset before Close() because it shouldn't run if any async |
234 // operation is in progress. | 232 // operation is in progress. |
235 async_in_progress_ = false; | 233 async_in_progress_ = false; |
236 if (orphaned_) | 234 if (orphaned_) |
237 CloseAndDelete(); | 235 CloseAndDelete(); |
238 else | 236 else |
239 callback.Run(result.result); | 237 callback.Run(result.result); |
240 } | 238 } |
241 | 239 |
242 } // namespace net | 240 } // namespace net |
OLD | NEW |