Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(790)

Unified Diff: chrome/browser/android/offline_pages/request_coordinator_factory.cc

Issue 2432593002: [Offline Pages] Add basic evaluation tests and related changes. (Closed)
Patch Set: Fix build failure. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/android/offline_pages/request_coordinator_factory.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/offline_pages/request_coordinator_factory.cc
diff --git a/chrome/browser/android/offline_pages/request_coordinator_factory.cc b/chrome/browser/android/offline_pages/request_coordinator_factory.cc
index 89cffad81553bbb1a11c38a73f0831772742ff22..527529a4cca60819454b133f58ca99a0a8c89b55 100644
--- a/chrome/browser/android/offline_pages/request_coordinator_factory.cc
+++ b/chrome/browser/android/offline_pages/request_coordinator_factory.cc
@@ -28,13 +28,72 @@
#include "content/public/browser/browser_thread.h"
#include "net/nqe/network_quality_estimator.h"
+#if !defined(OFFICIAL_BUILD)
+#include "chrome/browser/android/offline_pages/evaluation/evaluation_test_scheduler.h"
+#endif
+
namespace offline_pages {
+namespace {
+const bool kPreferUntriedRequest = false;
+const bool kPreferEarlierRequest = true;
+const bool kPreferRetryCountOverRecency = false;
+const int kMaxStartedTries = 4;
+const int kMaxCompletedTries = 1;
+const int kImmediateRequestExpirationTimeInSeconds = 3600;
+}
+
RequestCoordinatorFactory::RequestCoordinatorFactory()
: BrowserContextKeyedServiceFactory(
"OfflineRequestCoordinator",
BrowserContextDependencyManager::GetInstance()) {}
+#if !defined(OFFICIAL_BUILD)
+// static
+std::unique_ptr<KeyedService> RequestCoordinatorFactory::GetTestingFactory(
+ content::BrowserContext* context) {
+ // Create a new OfflinerPolicy with a larger background processing
+ // budget (3600 sec). Other values are the same with default ones.
+ std::unique_ptr<OfflinerPolicy> policy(new OfflinerPolicy(
+ kPreferUntriedRequest, kPreferEarlierRequest,
+ kPreferRetryCountOverRecency, kMaxStartedTries, kMaxCompletedTries,
+ kImmediateRequestExpirationTimeInSeconds));
+ std::unique_ptr<OfflinerFactory> prerenderer_offliner(
+ new PrerenderingOfflinerFactory(context));
+
+ scoped_refptr<base::SequencedTaskRunner> background_task_runner =
+ content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner(
+ content::BrowserThread::GetBlockingPool()->GetSequenceToken());
+ Profile* profile = Profile::FromBrowserContext(context);
+ base::FilePath queue_store_path =
+ profile->GetPath().Append(chrome::kOfflinePageRequestQueueDirname);
+
+ std::unique_ptr<RequestQueueStoreSQL> queue_store(
+ new RequestQueueStoreSQL(background_task_runner, queue_store_path));
+ std::unique_ptr<RequestQueue> queue(new RequestQueue(std::move(queue_store)));
+ std::unique_ptr<android::EvaluationTestScheduler> scheduler(
+ new android::EvaluationTestScheduler());
+ net::NetworkQualityEstimator::NetworkQualityProvider*
+ network_quality_estimator =
+ UINetworkQualityEstimatorServiceFactory::GetForProfile(profile);
+ // TODO(fgorski): Something needs to keep the handle to the Notification
+ // dispatcher.
+ std::unique_ptr<RequestCoordinator> request_coordinator =
+ base::MakeUnique<RequestCoordinator>(
+ std::move(policy), std::move(prerenderer_offliner), std::move(queue),
+ std::move(scheduler), network_quality_estimator);
+ request_coordinator->SetImmediateScheduleCallbackForTest(
+ base::Bind(&android::EvaluationTestScheduler::ImmediateScheduleCallback,
+ base::Unretained(scheduler.get())));
+
+ DownloadNotifyingObserver::CreateAndStartObserving(
+ request_coordinator.get(),
+ base::MakeUnique<android::OfflinePageNotificationBridge>());
+
+ return std::move(request_coordinator);
+}
+#endif
+
// static
RequestCoordinatorFactory* RequestCoordinatorFactory::GetInstance() {
return base::Singleton<RequestCoordinatorFactory>::get();
« no previous file with comments | « chrome/browser/android/offline_pages/request_coordinator_factory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698