| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 bool ReadFile(const base::FilePath& file_path, std::string* content) { | 88 bool ReadFile(const base::FilePath& file_path, std::string* content) { |
| 89 base::File file(file_path, base::File::FLAG_OPEN | base::File::FLAG_READ); | 89 base::File file(file_path, base::File::FLAG_OPEN | base::File::FLAG_READ); |
| 90 if (!file.IsValid()) { | 90 if (!file.IsValid()) { |
| 91 LOG(ERROR) << "Cannot open " << file_path.MaybeAsASCII() << ": " | 91 LOG(ERROR) << "Cannot open " << file_path.MaybeAsASCII() << ": " |
| 92 << base::File::ErrorToString(file.error_details()); | 92 << base::File::ErrorToString(file.error_details()); |
| 93 return false; | 93 return false; |
| 94 } | 94 } |
| 95 | 95 |
| 96 STLClearObject(content); | 96 base::STLClearObject(content); |
| 97 int rv; | 97 int rv; |
| 98 do { | 98 do { |
| 99 char buf[4096]; | 99 char buf[4096]; |
| 100 rv = file.ReadAtCurrentPos(buf, sizeof buf); | 100 rv = file.ReadAtCurrentPos(buf, sizeof buf); |
| 101 if (rv == -1) { | 101 if (rv == -1) { |
| 102 LOG(ERROR) << "Cannot read " << file_path.MaybeAsASCII() << ": " | 102 LOG(ERROR) << "Cannot read " << file_path.MaybeAsASCII() << ": " |
| 103 << base::File::ErrorToString(file.error_details()); | 103 << base::File::ErrorToString(file.error_details()); |
| 104 return false; | 104 return false; |
| 105 } | 105 } |
| 106 content->append(buf, rv); | 106 content->append(buf, rv); |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 return false; | 613 return false; |
| 614 } | 614 } |
| 615 | 615 |
| 616 DeviceAddListener add_listener(usb_service_, device_address_, -1); | 616 DeviceAddListener add_listener(usb_service_, device_address_, -1); |
| 617 device_ = add_listener.WaitForAdd(); | 617 device_ = add_listener.WaitForAdd(); |
| 618 DCHECK(device_.get()); | 618 DCHECK(device_.get()); |
| 619 return true; | 619 return true; |
| 620 } | 620 } |
| 621 | 621 |
| 622 } // namespace device | 622 } // namespace device |
| OLD | NEW |