Chromium Code Reviews| Index: base/files/file.cc |
| diff --git a/base/files/file.cc b/base/files/file.cc |
| index 47b9f88f1888d1d3cf4b70070b460bd8e8880289..036d43b33c50d6efd816d64005c6a18ce4ab34e9 100644 |
| --- a/base/files/file.cc |
| +++ b/base/files/file.cc |
| @@ -50,13 +50,12 @@ File::File(Error error_details) |
| async_(false) { |
| } |
| -File::File(RValue other) |
| - : file_(other.object->TakePlatformFile()), |
| - tracing_path_(other.object->tracing_path_), |
| - error_details_(other.object->error_details()), |
| - created_(other.object->created()), |
| - async_(other.object->async_) { |
| -} |
| +File::File(File&& other) |
| + : file_(other.TakePlatformFile()), |
| + tracing_path_(other.tracing_path_), |
| + error_details_(other.error_details()), |
| + created_(other.created()), |
| + async_(other.async_) {} |
| File::~File() { |
| // Go through the AssertIOAllowed logic. |
| @@ -72,15 +71,14 @@ File File::CreateForAsyncHandle(PlatformFile platform_file) { |
| return file.Pass(); |
| } |
| -File& File::operator=(RValue other) { |
| - if (this != other.object) { |
|
dcheng
2015/10/13 21:03:09
As far as I can tell, these checks were all defens
|
| - Close(); |
| - SetPlatformFile(other.object->TakePlatformFile()); |
| - tracing_path_ = other.object->tracing_path_; |
| - error_details_ = other.object->error_details(); |
| - created_ = other.object->created(); |
| - async_ = other.object->async_; |
| - } |
| +File& File::operator=(File&& other) { |
| + DCHECK_NE(this, &other); |
| + Close(); |
|
danakj
2015/10/15 23:35:05
This close would be destructive if this == &other.
|
| + SetPlatformFile(other.TakePlatformFile()); |
| + tracing_path_ = other.tracing_path_; |
|
danakj
2015/10/15 23:35:05
we should probably be move()ing all the arguments
dcheng
2015/10/16 00:40:01
It seems weird to std::move() an integral type.
F
danakj
2015/10/16 00:44:24
It's okay if it's not moveable, the code would wor
|
| + error_details_ = other.error_details(); |
| + created_ = other.created(); |
| + async_ = other.async_; |
| return *this; |
| } |