OLD | NEW |
1 // Copyright 2015 The Crashpad Authors. All rights reserved. | 1 // Copyright 2015 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 } | 62 } |
63 | 63 |
64 FileReader::FileReader() | 64 FileReader::FileReader() |
65 : file_(), | 65 : file_(), |
66 weak_file_handle_file_reader_(kInvalidFileHandle) { | 66 weak_file_handle_file_reader_(kInvalidFileHandle) { |
67 } | 67 } |
68 | 68 |
69 FileReader::~FileReader() { | 69 FileReader::~FileReader() { |
70 } | 70 } |
71 | 71 |
72 bool FileReader::Open(const base::FilePath& path, | 72 bool FileReader::Open(const base::FilePath& path) { |
73 FileWriteMode write_mode, | |
74 FilePermissions permissions) { | |
75 CHECK(!file_.is_valid()); | 73 CHECK(!file_.is_valid()); |
76 file_.reset(LoggingOpenFileForRead(path)); | 74 file_.reset(LoggingOpenFileForRead(path)); |
77 if (!file_.is_valid()) { | 75 if (!file_.is_valid()) { |
78 return false; | 76 return false; |
79 } | 77 } |
80 | 78 |
81 weak_file_handle_file_reader_.set_file_handle(file_.get()); | 79 weak_file_handle_file_reader_.set_file_handle(file_.get()); |
82 return true; | 80 return true; |
83 } | 81 } |
84 | 82 |
85 void FileReader::Close() { | 83 void FileReader::Close() { |
86 CHECK(file_.is_valid()); | 84 CHECK(file_.is_valid()); |
87 | 85 |
88 weak_file_handle_file_reader_.set_file_handle(kInvalidFileHandle); | 86 weak_file_handle_file_reader_.set_file_handle(kInvalidFileHandle); |
89 file_.reset(); | 87 file_.reset(); |
90 } | 88 } |
91 | 89 |
92 ssize_t FileReader::Read(void* data, size_t size) { | 90 ssize_t FileReader::Read(void* data, size_t size) { |
93 DCHECK(file_.is_valid()); | 91 DCHECK(file_.is_valid()); |
94 return weak_file_handle_file_reader_.Read(data, size); | 92 return weak_file_handle_file_reader_.Read(data, size); |
95 } | 93 } |
96 | 94 |
97 FileOffset FileReader::Seek(FileOffset offset, int whence) { | 95 FileOffset FileReader::Seek(FileOffset offset, int whence) { |
98 DCHECK(file_.is_valid()); | 96 DCHECK(file_.is_valid()); |
99 return weak_file_handle_file_reader_.Seek(offset, whence); | 97 return weak_file_handle_file_reader_.Seek(offset, whence); |
100 } | 98 } |
101 | 99 |
102 } // namespace crashpad | 100 } // namespace crashpad |
OLD | NEW |