| 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 <sstream> | 6 #include <sstream> |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 // Creates the DomDistillerService and creates and starts the extraction | 344 // Creates the DomDistillerService and creates and starts the extraction |
| 345 // request. | 345 // request. |
| 346 void Start() { | 346 void Start() { |
| 347 const base::CommandLine& command_line = | 347 const base::CommandLine& command_line = |
| 348 *base::CommandLine::ForCurrentProcess(); | 348 *base::CommandLine::ForCurrentProcess(); |
| 349 FileToUrlMap file_to_url_map; | 349 FileToUrlMap file_to_url_map; |
| 350 requests_ = ContentExtractionRequest::CreateForCommandLine( | 350 requests_ = ContentExtractionRequest::CreateForCommandLine( |
| 351 command_line, &file_to_url_map); | 351 command_line, &file_to_url_map); |
| 352 content::BrowserContext* context = | 352 content::BrowserContext* context = |
| 353 shell()->web_contents()->GetBrowserContext(); | 353 shell()->web_contents()->GetBrowserContext(); |
| 354 service_ = CreateDomDistillerService(context, | 354 service_ = |
| 355 db_dir_.path(), | 355 CreateDomDistillerService(context, db_dir_.GetPath(), file_to_url_map); |
| 356 file_to_url_map); | |
| 357 PumpQueue(); | 356 PumpQueue(); |
| 358 } | 357 } |
| 359 | 358 |
| 360 void PumpQueue() { | 359 void PumpQueue() { |
| 361 while (pending_tasks_ < max_tasks_ && next_request_ < requests_.size()) { | 360 while (pending_tasks_ < max_tasks_ && next_request_ < requests_.size()) { |
| 362 requests_[next_request_]->Start( | 361 requests_[next_request_]->Start( |
| 363 service_.get(), | 362 service_.get(), |
| 364 shell()->web_contents()->GetContainerBounds().size(), | 363 shell()->web_contents()->GetContainerBounds().size(), |
| 365 base::Bind(&ContentExtractor::FinishRequest, base::Unretained(this))); | 364 base::Bind(&ContentExtractor::FinishRequest, base::Unretained(this))); |
| 366 ++next_request_; | 365 ++next_request_; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 protobuf_output_stream_; | 438 protobuf_output_stream_; |
| 440 }; | 439 }; |
| 441 | 440 |
| 442 IN_PROC_BROWSER_TEST_F(ContentExtractor, MANUAL_ExtractUrl) { | 441 IN_PROC_BROWSER_TEST_F(ContentExtractor, MANUAL_ExtractUrl) { |
| 443 SetDistillerJavaScriptWorldId(content::ISOLATED_WORLD_ID_CONTENT_END); | 442 SetDistillerJavaScriptWorldId(content::ISOLATED_WORLD_ID_CONTENT_END); |
| 444 Start(); | 443 Start(); |
| 445 base::RunLoop().Run(); | 444 base::RunLoop().Run(); |
| 446 } | 445 } |
| 447 | 446 |
| 448 } // namespace dom_distiller | 447 } // namespace dom_distiller |
| OLD | NEW |