OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/extensions/extension_record_api.h" | 5 #include "chrome/browser/extensions/extension_record_api.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 RunPageCyclerFunction::~RunPageCyclerFunction() {} | 44 RunPageCyclerFunction::~RunPageCyclerFunction() {} |
45 | 45 |
46 bool RunPageCyclerFunction::RunImpl() { | 46 bool RunPageCyclerFunction::RunImpl() { |
47 if (!ParseJSParameters()) | 47 if (!ParseJSParameters()) |
48 return false; | 48 return false; |
49 | 49 |
50 // If we've had any errors reportable to the JS caller so far (in | 50 // If we've had any errors reportable to the JS caller so far (in |
51 // parameter parsing) then return a list of such errors, else perform | 51 // parameter parsing) then return a list of such errors, else perform |
52 // RunTestBrowser on the BlockingPool. | 52 // RunTestBrowser on the BlockingPool. |
53 if (!errors_.empty()) { | 53 if (!errors_.empty()) { |
54 result_.reset(record::CaptureURLs::Result::Create(errors_)); | 54 SetSingleResult(record::CaptureURLs::Result::Create(errors_)); |
55 SendResponse(true); | 55 SendResponse(true); |
56 } else { | 56 } else { |
57 content::BrowserThread::PostBlockingPoolTask(FROM_HERE, | 57 content::BrowserThread::PostBlockingPoolTask(FROM_HERE, |
58 base::Bind(&RunPageCyclerFunction::RunTestBrowser, this)); | 58 base::Bind(&RunPageCyclerFunction::RunTestBrowser, this)); |
59 process_strategy_->PumpBlockingPool(); // Test purposes only. | 59 process_strategy_->PumpBlockingPool(); // Test purposes only. |
60 } | 60 } |
61 | 61 |
62 return true; | 62 return true; |
63 } | 63 } |
64 | 64 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 } | 171 } |
172 | 172 |
173 // CaptureURLsFunction adds "record-mode" to sub-browser call, and returns | 173 // CaptureURLsFunction adds "record-mode" to sub-browser call, and returns |
174 // just the (possibly empty) error list. | 174 // just the (possibly empty) error list. |
175 void CaptureURLsFunction::AddSwitches(CommandLine* line) { | 175 void CaptureURLsFunction::AddSwitches(CommandLine* line) { |
176 if (!line->HasSwitch(switches::kRecordMode)) | 176 if (!line->HasSwitch(switches::kRecordMode)) |
177 line->AppendSwitch(switches::kRecordMode); | 177 line->AppendSwitch(switches::kRecordMode); |
178 } | 178 } |
179 | 179 |
180 void CaptureURLsFunction::Finish() { | 180 void CaptureURLsFunction::Finish() { |
181 result_.reset(record::CaptureURLs::Result::Create(errors_)); | 181 SetSingleResult(record::CaptureURLs::Result::Create(errors_)); |
182 SendResponse(true); | 182 SendResponse(true); |
183 } | 183 } |
184 | 184 |
185 | 185 |
186 // ReplayURLsFunction ------------------------------------------------ | 186 // ReplayURLsFunction ------------------------------------------------ |
187 | 187 |
188 ReplayURLsFunction::ReplayURLsFunction() | 188 ReplayURLsFunction::ReplayURLsFunction() |
189 : RunPageCyclerFunction(new ProductionProcessStrategy()), | 189 : RunPageCyclerFunction(new ProductionProcessStrategy()), |
190 run_time_ms_(0) { | 190 run_time_ms_(0) { |
191 } | 191 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 run_time_ms_ = (base::Time::NowFromSystemTime() - timer_).InMilliseconds(); | 238 run_time_ms_ = (base::Time::NowFromSystemTime() - timer_).InMilliseconds(); |
239 } | 239 } |
240 | 240 |
241 void ReplayURLsFunction::Finish() { | 241 void ReplayURLsFunction::Finish() { |
242 record::ReplayURLsResult result; | 242 record::ReplayURLsResult result; |
243 | 243 |
244 result.run_time = run_time_ms_; | 244 result.run_time = run_time_ms_; |
245 result.stats = stats_; | 245 result.stats = stats_; |
246 result.errors = errors_; | 246 result.errors = errors_; |
247 | 247 |
248 result_.reset(record::ReplayURLs::Result::Create(result)); | 248 SetSingleResult(record::ReplayURLs::Result::Create(result)); |
249 SendResponse(true); | 249 SendResponse(true); |
250 } | 250 } |
251 | 251 |
OLD | NEW |