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 <sstream> | 5 #include <sstream> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/string_split.h" | 13 #include "base/strings/string_split.h" |
14 #include "components/dom_distiller/content/distiller_page_web_contents.h" | 14 #include "components/dom_distiller/content/distiller_page_web_contents.h" |
| 15 #include "components/dom_distiller/core/article_entry.h" |
15 #include "components/dom_distiller/core/distiller.h" | 16 #include "components/dom_distiller/core/distiller.h" |
16 #include "components/dom_distiller/core/dom_distiller_database.h" | |
17 #include "components/dom_distiller/core/dom_distiller_service.h" | 17 #include "components/dom_distiller/core/dom_distiller_service.h" |
18 #include "components/dom_distiller/core/dom_distiller_store.h" | 18 #include "components/dom_distiller/core/dom_distiller_store.h" |
19 #include "components/dom_distiller/core/proto/distilled_article.pb.h" | 19 #include "components/dom_distiller/core/proto/distilled_article.pb.h" |
20 #include "components/dom_distiller/core/proto/distilled_page.pb.h" | 20 #include "components/dom_distiller/core/proto/distilled_page.pb.h" |
21 #include "components/dom_distiller/core/task_tracker.h" | 21 #include "components/dom_distiller/core/task_tracker.h" |
| 22 #include "components/leveldb_proto/proto_database.h" |
| 23 #include "components/leveldb_proto/proto_database_impl.h" |
22 #include "content/public/browser/browser_context.h" | 24 #include "content/public/browser/browser_context.h" |
23 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
24 #include "content/public/test/content_browser_test.h" | 26 #include "content/public/test/content_browser_test.h" |
25 #include "content/shell/browser/shell.h" | 27 #include "content/shell/browser/shell.h" |
26 #include "google/protobuf/io/coded_stream.h" | 28 #include "google/protobuf/io/coded_stream.h" |
27 #include "google/protobuf/io/zero_copy_stream_impl_lite.h" | 29 #include "google/protobuf/io/zero_copy_stream_impl_lite.h" |
28 #include "net/dns/mock_host_resolver.h" | 30 #include "net/dns/mock_host_resolver.h" |
29 #include "third_party/dom_distiller_js/dom_distiller.pb.h" | 31 #include "third_party/dom_distiller_js/dom_distiller.pb.h" |
30 #include "ui/base/resource/resource_bundle.h" | 32 #include "ui/base/resource/resource_bundle.h" |
31 | 33 |
(...skipping 30 matching lines...) Expand all Loading... |
62 | 64 |
63 scoped_ptr<DomDistillerService> CreateDomDistillerService( | 65 scoped_ptr<DomDistillerService> CreateDomDistillerService( |
64 content::BrowserContext* context, | 66 content::BrowserContext* context, |
65 const base::FilePath& db_path) { | 67 const base::FilePath& db_path) { |
66 scoped_refptr<base::SequencedTaskRunner> background_task_runner = | 68 scoped_refptr<base::SequencedTaskRunner> background_task_runner = |
67 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( | 69 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( |
68 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); | 70 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); |
69 | 71 |
70 // TODO(cjhopman): use an in-memory database instead of an on-disk one with | 72 // TODO(cjhopman): use an in-memory database instead of an on-disk one with |
71 // temporary directory. | 73 // temporary directory. |
72 scoped_ptr<DomDistillerDatabase> db( | 74 scoped_ptr<leveldb_proto::ProtoDatabaseImpl<ArticleEntry> > db( |
73 new DomDistillerDatabase(background_task_runner)); | 75 new leveldb_proto::ProtoDatabaseImpl<ArticleEntry>( |
| 76 background_task_runner)); |
74 scoped_ptr<DomDistillerStore> dom_distiller_store(new DomDistillerStore( | 77 scoped_ptr<DomDistillerStore> dom_distiller_store(new DomDistillerStore( |
75 db.PassAs<DomDistillerDatabaseInterface>(), db_path)); | 78 db.PassAs<leveldb_proto::ProtoDatabase<ArticleEntry> >(), db_path)); |
76 | 79 |
77 scoped_ptr<DistillerPageFactory> distiller_page_factory( | 80 scoped_ptr<DistillerPageFactory> distiller_page_factory( |
78 new DistillerPageWebContentsFactory(context)); | 81 new DistillerPageWebContentsFactory(context)); |
79 scoped_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory( | 82 scoped_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory( |
80 new DistillerURLFetcherFactory(context->GetRequestContext())); | 83 new DistillerURLFetcherFactory(context->GetRequestContext())); |
81 | 84 |
82 dom_distiller::proto::DomDistillerOptions options; | 85 dom_distiller::proto::DomDistillerOptions options; |
83 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kExtractTextOnly)) { | 86 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kExtractTextOnly)) { |
84 options.set_extract_text_only(true); | 87 options.set_extract_text_only(true); |
85 } | 88 } |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 std::string output_data_; | 316 std::string output_data_; |
314 scoped_ptr<google::protobuf::io::StringOutputStream> protobuf_output_stream_; | 317 scoped_ptr<google::protobuf::io::StringOutputStream> protobuf_output_stream_; |
315 }; | 318 }; |
316 | 319 |
317 IN_PROC_BROWSER_TEST_F(ContentExtractor, MANUAL_ExtractUrl) { | 320 IN_PROC_BROWSER_TEST_F(ContentExtractor, MANUAL_ExtractUrl) { |
318 Start(); | 321 Start(); |
319 base::RunLoop().Run(); | 322 base::RunLoop().Run(); |
320 } | 323 } |
321 | 324 |
322 } // namespace dom_distiller | 325 } // namespace dom_distiller |
OLD | NEW |