OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/test/chromedriver/util.h" | 5 #include "chrome/test/chromedriver/util.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/file_enumerator.h" | 9 #include "base/files/file_enumerator.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 namespace { | 83 namespace { |
84 | 84 |
85 Status UnzipArchive(const base::FilePath& unzip_dir, | 85 Status UnzipArchive(const base::FilePath& unzip_dir, |
86 const std::string& bytes) { | 86 const std::string& bytes) { |
87 base::ScopedTempDir dir; | 87 base::ScopedTempDir dir; |
88 if (!dir.CreateUniqueTempDir()) | 88 if (!dir.CreateUniqueTempDir()) |
89 return Status(kUnknownError, "unable to create temp dir"); | 89 return Status(kUnknownError, "unable to create temp dir"); |
90 | 90 |
91 base::FilePath archive = dir.path().AppendASCII("temp.zip"); | 91 base::FilePath archive = dir.path().AppendASCII("temp.zip"); |
92 int length = bytes.length(); | 92 int length = bytes.length(); |
93 if (file_util::WriteFile(archive, bytes.c_str(), length) != length) | 93 if (base::WriteFile(archive, bytes.c_str(), length) != length) |
94 return Status(kUnknownError, "could not write file to temp dir"); | 94 return Status(kUnknownError, "could not write file to temp dir"); |
95 | 95 |
96 if (!zip::Unzip(archive, unzip_dir)) | 96 if (!zip::Unzip(archive, unzip_dir)) |
97 return Status(kUnknownError, "could not unzip archive"); | 97 return Status(kUnknownError, "could not unzip archive"); |
98 return Status(kOk); | 98 return Status(kOk); |
99 } | 99 } |
100 | 100 |
101 // Stream for writing binary data. | 101 // Stream for writing binary data. |
102 class DataOutputStream { | 102 class DataOutputStream { |
103 public: | 103 public: |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 if (first_file.empty()) | 394 if (first_file.empty()) |
395 return Status(kUnknownError, "contained 0 files"); | 395 return Status(kUnknownError, "contained 0 files"); |
396 | 396 |
397 base::FilePath second_file = enumerator.Next(); | 397 base::FilePath second_file = enumerator.Next(); |
398 if (!second_file.empty()) | 398 if (!second_file.empty()) |
399 return Status(kUnknownError, "contained multiple files"); | 399 return Status(kUnknownError, "contained multiple files"); |
400 | 400 |
401 *file = first_file; | 401 *file = first_file; |
402 return Status(kOk); | 402 return Status(kOk); |
403 } | 403 } |
OLD | NEW |