Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/previews/core/previews_io_data.h" | 5 #include "components/previews/core/previews_io_data.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/sequenced_task_runner.h" | 12 #include "base/sequenced_task_runner.h" |
| 13 #include "base/time/default_clock.h" | 13 #include "base/time/default_clock.h" |
| 14 #include "components/previews/core/previews_black_list.h" | 14 #include "components/previews/core/previews_black_list.h" |
| 15 #include "components/previews/core/previews_experiments.h" | |
| 15 #include "components/previews/core/previews_opt_out_store.h" | 16 #include "components/previews/core/previews_opt_out_store.h" |
| 16 #include "components/previews/core/previews_ui_service.h" | 17 #include "components/previews/core/previews_ui_service.h" |
| 18 #include "net/nqe/network_quality_estimator.h" | |
| 19 #include "net/url_request/url_request.h" | |
| 20 #include "net/url_request/url_request_context.h" | |
| 17 #include "url/gurl.h" | 21 #include "url/gurl.h" |
| 18 | 22 |
| 19 namespace previews { | 23 namespace previews { |
| 20 | 24 |
| 21 PreviewsIOData::PreviewsIOData( | 25 PreviewsIOData::PreviewsIOData( |
| 22 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, | 26 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, |
| 23 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) | 27 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) |
| 24 : ui_task_runner_(ui_task_runner), | 28 : ui_task_runner_(ui_task_runner), |
| 25 io_task_runner_(io_task_runner), | 29 io_task_runner_(io_task_runner), |
| 26 weak_factory_(this) {} | 30 weak_factory_(this) {} |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 57 DCHECK(io_task_runner_->BelongsToCurrentThread()); | 61 DCHECK(io_task_runner_->BelongsToCurrentThread()); |
| 58 previews_black_list_->AddPreviewNavigation(url, opt_out, type); | 62 previews_black_list_->AddPreviewNavigation(url, opt_out, type); |
| 59 } | 63 } |
| 60 | 64 |
| 61 void PreviewsIOData::ClearBlackList(base::Time begin_time, | 65 void PreviewsIOData::ClearBlackList(base::Time begin_time, |
| 62 base::Time end_time) { | 66 base::Time end_time) { |
| 63 DCHECK(io_task_runner_->BelongsToCurrentThread()); | 67 DCHECK(io_task_runner_->BelongsToCurrentThread()); |
| 64 previews_black_list_->ClearBlackList(begin_time, end_time); | 68 previews_black_list_->ClearBlackList(begin_time, end_time); |
| 65 } | 69 } |
| 66 | 70 |
| 71 bool PreviewsIOData::ShouldAllowPreview(const net::URLRequest& request, | |
| 72 PreviewsType type) const { | |
| 73 if (!IsOfflinePreviewsEnabled()) | |
| 74 return false; | |
| 75 if (!previews_black_list_ || | |
| 76 !previews_black_list_->IsLoadedAndAllowed(request.url(), type)) { | |
|
tbansal1
2016/10/06 14:55:52
Also, how does a host that is blacklisted gets off
RyanSturm
2016/10/06 15:52:16
It's a timing mechanism (90 days I believe) contro
| |
| 77 return false; | |
| 78 } | |
| 79 net::NetworkQualityEstimator* network_quality_estimator = | |
| 80 request.context()->network_quality_estimator(); | |
| 81 if (!network_quality_estimator) | |
| 82 return false; | |
| 83 | |
| 84 net::EffectiveConnectionType effective_connection_type = | |
| 85 network_quality_estimator->GetEffectiveConnectionType(); | |
| 86 return effective_connection_type >= net::EFFECTIVE_CONNECTION_TYPE_OFFLINE && | |
| 87 effective_connection_type <= net::EFFECTIVE_CONNECTION_TYPE_SLOW_2G; | |
| 88 } | |
| 89 | |
| 67 } // namespace previews | 90 } // namespace previews |
| OLD | NEW |