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

Side by Side Diff: chrome/browser/android/offline_pages/evaluation/evaluation_test_scheduler.cc

Issue 2529603004: [Offline Pages] Expanding event logger to be used by harness. (Closed)
Patch Set: more comments. Created 4 years 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 unified diff | Download patch
OLDNEW
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 "chrome/browser/android/offline_pages/evaluation/evaluation_test_schedu ler.h" 5 #include "chrome/browser/android/offline_pages/evaluation/evaluation_test_schedu ler.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/threading/thread_task_runner_handle.h" 8 #include "base/threading/thread_task_runner_handle.h"
9 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h" 9 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/profiles/profile_manager.h" 11 #include "chrome/browser/profiles/profile_manager.h"
12 #include "components/offline_pages/background/device_conditions.h" 12 #include "components/offline_pages/background/device_conditions.h"
13 #include "components/offline_pages/background/request_coordinator.h" 13 #include "components/offline_pages/background/request_coordinator.h"
14 #include "components/offline_pages/offline_event_logger.h"
14 #include "net/base/network_change_notifier.h" 15 #include "net/base/network_change_notifier.h"
15 16
16 namespace offline_pages { 17 namespace offline_pages {
17 18
18 namespace android { 19 namespace android {
19 20
20 namespace { 21 namespace {
21 22
23 const char kLogTag[] = "EvaluationTestScheduler";
24
22 void StartProcessing(); 25 void StartProcessing();
23 26
24 void ProcessingDoneCallback(bool result) { 27 void ProcessingDoneCallback(bool result) {
25 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, 28 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
26 base::Bind(&StartProcessing)); 29 base::Bind(&StartProcessing));
27 } 30 }
28 31
29 void GetAllRequestsDone( 32 void GetAllRequestsDone(
30 std::vector<std::unique_ptr<SavePageRequest>> requests) { 33 std::vector<std::unique_ptr<SavePageRequest>> requests) {
31 if (requests.size() > 0) { 34 if (requests.size() > 0) {
(...skipping 12 matching lines...) Expand all
44 Profile* profile = ProfileManager::GetLastUsedProfile(); 47 Profile* profile = ProfileManager::GetLastUsedProfile();
45 RequestCoordinator* coordinator = 48 RequestCoordinator* coordinator =
46 RequestCoordinatorFactory::GetInstance()->GetForBrowserContext(profile); 49 RequestCoordinatorFactory::GetInstance()->GetForBrowserContext(profile);
47 coordinator->GetAllRequests(base::Bind(&GetAllRequestsDone)); 50 coordinator->GetAllRequests(base::Bind(&GetAllRequestsDone));
48 } 51 }
49 52
50 } // namespace 53 } // namespace
51 54
52 void EvaluationTestScheduler::Schedule( 55 void EvaluationTestScheduler::Schedule(
53 const TriggerConditions& trigger_conditions) { 56 const TriggerConditions& trigger_conditions) {
57 Profile* profile = ProfileManager::GetLastUsedProfile();
58 if (!coordinator_) {
59 coordinator_ =
60 RequestCoordinatorFactory::GetInstance()->GetForBrowserContext(profile);
61 // It's not expected that the coordinator would be nullptr since this bridge
62 // would only be used for testing scenario.
63 DCHECK(coordinator_);
64 }
65 coordinator_->GetLogger()->RecordActivity(std::string(kLogTag) +
66 " Start schedule!");
54 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, 67 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
55 base::Bind(&StartProcessing)); 68 base::Bind(&StartProcessing));
56 } 69 }
57 70
58 void EvaluationTestScheduler::BackupSchedule( 71 void EvaluationTestScheduler::BackupSchedule(
59 const TriggerConditions& trigger_conditions, 72 const TriggerConditions& trigger_conditions,
60 long delay_in_seconds) {} 73 long delay_in_seconds) {}
61 74
62 void EvaluationTestScheduler::Unschedule() {} 75 void EvaluationTestScheduler::Unschedule() {}
63 76
64 void EvaluationTestScheduler::ImmediateScheduleCallback(bool result) { 77 void EvaluationTestScheduler::ImmediateScheduleCallback(bool result) {
65 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, 78 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
66 base::Bind(&StartProcessing)); 79 base::Bind(&StartProcessing));
67 } 80 }
68 81
69 } // namespace android 82 } // namespace android
70 } // namespace offline_pages 83 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698