Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: chrome/test/chromedriver/util.cc

Issue 23542005: [chromedriver] Improve timeout behavior. Prompted by user who executes script on busy page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 110
111 void WriteUInt32(uint32 data) { 111 void WriteUInt32(uint32 data) {
112 WriteBytes(&data, sizeof(data)); 112 WriteBytes(&data, sizeof(data));
113 } 113 }
114 114
115 void WriteString(const std::string& data) { 115 void WriteString(const std::string& data) {
116 WriteBytes(data.c_str(), data.length()); 116 WriteBytes(data.c_str(), data.length());
117 } 117 }
118 118
119 void WriteBytes(const void* bytes, int size) { 119 void WriteBytes(const void* bytes, int size) {
120 if (!size)
121 return;
120 size_t next = buffer_.length(); 122 size_t next = buffer_.length();
121 buffer_.resize(next + size); 123 buffer_.resize(next + size);
122 memcpy(&buffer_[next], bytes, size); 124 memcpy(&buffer_[next], bytes, size);
123 } 125 }
124 126
125 const std::string& buffer() const { return buffer_; } 127 const std::string& buffer() const { return buffer_; }
126 128
127 private: 129 private:
128 std::string buffer_; 130 std::string buffer_;
129 }; 131 };
(...skipping 13 matching lines...) Expand all
143 return ReadBytes(data, sizeof(*data)); 145 return ReadBytes(data, sizeof(*data));
144 } 146 }
145 147
146 bool ReadString(std::string* data, int length) { 148 bool ReadString(std::string* data, int length) {
147 if (length < 0) 149 if (length < 0)
148 return false; 150 return false;
149 // Check here to make sure we don't allocate wastefully. 151 // Check here to make sure we don't allocate wastefully.
150 if (iter_ + length > size_) 152 if (iter_ + length > size_)
151 return false; 153 return false;
152 data->resize(length); 154 data->resize(length);
155 if (length == 0)
156 return true;
153 return ReadBytes(&(*data)[0], length); 157 return ReadBytes(&(*data)[0], length);
154 } 158 }
155 159
156 bool ReadBytes(void* bytes, int size) { 160 bool ReadBytes(void* bytes, int size) {
157 if (iter_ + size > size_) 161 if (iter_ + size > size_)
158 return false; 162 return false;
159 memcpy(bytes, &data_[iter_], size); 163 memcpy(bytes, &data_[iter_], size);
160 iter_ += size; 164 iter_ += size;
161 return true; 165 return true;
162 } 166 }
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 if (first_file.empty()) 394 if (first_file.empty())
391 return Status(kUnknownError, "contained 0 files"); 395 return Status(kUnknownError, "contained 0 files");
392 396
393 base::FilePath second_file = enumerator.Next(); 397 base::FilePath second_file = enumerator.Next();
394 if (!second_file.empty()) 398 if (!second_file.empty())
395 return Status(kUnknownError, "contained multiple files"); 399 return Status(kUnknownError, "contained multiple files");
396 400
397 *file = first_file; 401 *file = first_file;
398 return Status(kOk); 402 return Status(kOk);
399 } 403 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698