| 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" |
| 11 #include "base/id_map.h" | 11 #include "base/id_map.h" |
| 12 #include "base/location.h" | 12 #include "base/location.h" |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 16 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
| 17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/strings/string_split.h" | 18 #include "base/strings/string_split.h" |
| 19 #include "base/task_scheduler/post_task.h" |
| 19 #include "base/threading/thread_task_runner_handle.h" | 20 #include "base/threading/thread_task_runner_handle.h" |
| 20 #include "components/dom_distiller/content/browser/distiller_javascript_utils.h" | 21 #include "components/dom_distiller/content/browser/distiller_javascript_utils.h" |
| 21 #include "components/dom_distiller/content/browser/distiller_page_web_contents.h
" | 22 #include "components/dom_distiller/content/browser/distiller_page_web_contents.h
" |
| 22 #include "components/dom_distiller/core/article_entry.h" | 23 #include "components/dom_distiller/core/article_entry.h" |
| 23 #include "components/dom_distiller/core/distilled_page_prefs.h" | 24 #include "components/dom_distiller/core/distilled_page_prefs.h" |
| 24 #include "components/dom_distiller/core/distiller.h" | 25 #include "components/dom_distiller/core/distiller.h" |
| 25 #include "components/dom_distiller/core/dom_distiller_service.h" | 26 #include "components/dom_distiller/core/dom_distiller_service.h" |
| 26 #include "components/dom_distiller/core/dom_distiller_store.h" | 27 #include "components/dom_distiller/core/dom_distiller_store.h" |
| 27 #include "components/dom_distiller/core/proto/distilled_article.pb.h" | 28 #include "components/dom_distiller/core/proto/distilled_article.pb.h" |
| 28 #include "components/dom_distiller/core/proto/distilled_page.pb.h" | 29 #include "components/dom_distiller/core/proto/distilled_page.pb.h" |
| 29 #include "components/dom_distiller/core/task_tracker.h" | 30 #include "components/dom_distiller/core/task_tracker.h" |
| 30 #include "components/leveldb_proto/proto_database.h" | 31 #include "components/leveldb_proto/proto_database.h" |
| 31 #include "components/leveldb_proto/proto_database_impl.h" | 32 #include "components/leveldb_proto/proto_database_impl.h" |
| 32 #include "components/sync_preferences/testing_pref_service_syncable.h" | 33 #include "components/sync_preferences/testing_pref_service_syncable.h" |
| 33 #include "content/public/browser/browser_context.h" | 34 #include "content/public/browser/browser_context.h" |
| 34 #include "content/public/browser/browser_thread.h" | |
| 35 #include "content/public/browser/storage_partition.h" | 35 #include "content/public/browser/storage_partition.h" |
| 36 #include "content/public/common/isolated_world_ids.h" | 36 #include "content/public/common/isolated_world_ids.h" |
| 37 #include "content/public/test/content_browser_test.h" | 37 #include "content/public/test/content_browser_test.h" |
| 38 #include "content/shell/browser/shell.h" | 38 #include "content/shell/browser/shell.h" |
| 39 #include "google/protobuf/io/coded_stream.h" | 39 #include "google/protobuf/io/coded_stream.h" |
| 40 #include "google/protobuf/io/zero_copy_stream_impl_lite.h" | 40 #include "google/protobuf/io/zero_copy_stream_impl_lite.h" |
| 41 #include "net/dns/mock_host_resolver.h" | 41 #include "net/dns/mock_host_resolver.h" |
| 42 #include "third_party/dom_distiller_js/dom_distiller.pb.h" | 42 #include "third_party/dom_distiller_js/dom_distiller.pb.h" |
| 43 #include "ui/base/resource/resource_bundle.h" | 43 #include "ui/base/resource/resource_bundle.h" |
| 44 | 44 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 // The pagination algorithm to use, one of "next", "pagenum". | 119 // The pagination algorithm to use, one of "next", "pagenum". |
| 120 const char* kPaginationAlgo = "pagination-algo"; | 120 const char* kPaginationAlgo = "pagination-algo"; |
| 121 | 121 |
| 122 // Maximum number of concurrent started extractor requests. | 122 // Maximum number of concurrent started extractor requests. |
| 123 const int kMaxExtractorTasks = 8; | 123 const int kMaxExtractorTasks = 8; |
| 124 | 124 |
| 125 std::unique_ptr<DomDistillerService> CreateDomDistillerService( | 125 std::unique_ptr<DomDistillerService> CreateDomDistillerService( |
| 126 content::BrowserContext* context, | 126 content::BrowserContext* context, |
| 127 const base::FilePath& db_path, | 127 const base::FilePath& db_path, |
| 128 const FileToUrlMap& file_to_url_map) { | 128 const FileToUrlMap& file_to_url_map) { |
| 129 base::SequencedWorkerPool* blocking_pool = | |
| 130 content::BrowserThread::GetBlockingPool(); | |
| 131 scoped_refptr<base::SequencedTaskRunner> background_task_runner = | 129 scoped_refptr<base::SequencedTaskRunner> background_task_runner = |
| 132 blocking_pool->GetSequencedTaskRunner(blocking_pool->GetSequenceToken()); | 130 base::CreateSequencedTaskRunnerWithTraits({base::MayBlock()}); |
| 133 | 131 |
| 134 // TODO(cjhopman): use an in-memory database instead of an on-disk one with | 132 // TODO(cjhopman): use an in-memory database instead of an on-disk one with |
| 135 // temporary directory. | 133 // temporary directory. |
| 136 std::unique_ptr<leveldb_proto::ProtoDatabaseImpl<ArticleEntry>> db( | 134 std::unique_ptr<leveldb_proto::ProtoDatabaseImpl<ArticleEntry>> db( |
| 137 new leveldb_proto::ProtoDatabaseImpl<ArticleEntry>( | 135 new leveldb_proto::ProtoDatabaseImpl<ArticleEntry>( |
| 138 background_task_runner)); | 136 background_task_runner)); |
| 139 std::unique_ptr<DomDistillerStore> dom_distiller_store( | 137 std::unique_ptr<DomDistillerStore> dom_distiller_store( |
| 140 new DomDistillerStore(std::move(db), db_path)); | 138 new DomDistillerStore(std::move(db), db_path)); |
| 141 | 139 |
| 142 std::unique_ptr<DistillerPageFactory> distiller_page_factory( | 140 std::unique_ptr<DistillerPageFactory> distiller_page_factory( |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 protobuf_output_stream_; | 439 protobuf_output_stream_; |
| 442 }; | 440 }; |
| 443 | 441 |
| 444 IN_PROC_BROWSER_TEST_F(ContentExtractor, MANUAL_ExtractUrl) { | 442 IN_PROC_BROWSER_TEST_F(ContentExtractor, MANUAL_ExtractUrl) { |
| 445 SetDistillerJavaScriptWorldId(content::ISOLATED_WORLD_ID_CONTENT_END); | 443 SetDistillerJavaScriptWorldId(content::ISOLATED_WORLD_ID_CONTENT_END); |
| 446 Start(); | 444 Start(); |
| 447 base::RunLoop().Run(); | 445 base::RunLoop().Run(); |
| 448 } | 446 } |
| 449 | 447 |
| 450 } // namespace dom_distiller | 448 } // namespace dom_distiller |
| OLD | NEW |