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