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

Side by Side Diff: chrome/browser/sync_file_system/sync_process_runner.cc

Issue 377563002: [SyncFS] Eliminate SyncFileSystemService dependency from SyncProcessRunner (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/sync_file_system/sync_process_runner.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/sync_file_system/sync_process_runner.h" 5 #include "chrome/browser/sync_file_system/sync_process_runner.h"
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "chrome/browser/sync_file_system/logger.h" 8 #include "chrome/browser/sync_file_system/logger.h"
9 #include "chrome/browser/sync_file_system/sync_file_system_service.h"
10 9
11 namespace sync_file_system { 10 namespace sync_file_system {
12 11
13 namespace { 12 namespace {
14 13
15 // Default delay when more changes are available. 14 // Default delay when more changes are available.
16 const int64 kSyncDelayInMilliseconds = 1 * base::Time::kMillisecondsPerSecond; 15 const int64 kSyncDelayInMilliseconds = 1 * base::Time::kMillisecondsPerSecond;
17 16
18 // Default delay when the previous change has had an error (but remote service 17 // Default delay when the previous change has had an error (but remote service
19 // is running). 18 // is running).
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 status == SYNC_STATUS_NO_CONFLICT || 58 status == SYNC_STATUS_NO_CONFLICT ||
60 status == SYNC_STATUS_NO_CHANGE_TO_SYNC || 59 status == SYNC_STATUS_NO_CHANGE_TO_SYNC ||
61 status == SYNC_STATUS_UNKNOWN_ORIGIN || 60 status == SYNC_STATUS_UNKNOWN_ORIGIN ||
62 status == SYNC_STATUS_RETRY; 61 status == SYNC_STATUS_RETRY;
63 } 62 }
64 63
65 } // namespace 64 } // namespace
66 65
67 SyncProcessRunner::SyncProcessRunner( 66 SyncProcessRunner::SyncProcessRunner(
68 const std::string& name, 67 const std::string& name,
69 SyncFileSystemService* sync_service, 68 Client* client,
70 scoped_ptr<TimerHelper> timer_helper, 69 scoped_ptr<TimerHelper> timer_helper,
71 int max_parallel_task) 70 int max_parallel_task)
72 : name_(name), 71 : name_(name),
73 sync_service_(sync_service), 72 client_(client),
74 max_parallel_task_(max_parallel_task), 73 max_parallel_task_(max_parallel_task),
75 running_tasks_(0), 74 running_tasks_(0),
76 timer_helper_(timer_helper.Pass()), 75 timer_helper_(timer_helper.Pass()),
77 current_delay_(0), 76 current_delay_(0),
78 last_delay_(0), 77 last_delay_(0),
79 pending_changes_(0), 78 pending_changes_(0),
80 factory_(this) { 79 factory_(this) {
81 DCHECK_LE(1, max_parallel_task_); 80 DCHECK_LE(1, max_parallel_task_);
82 81
83 DCHECK_EQ(1, max_parallel_task_) 82 DCHECK_EQ(1, max_parallel_task_)
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 Schedule(); 122 Schedule();
124 } 123 }
125 124
126 void SyncProcessRunner::OnChangesUpdated( 125 void SyncProcessRunner::OnChangesUpdated(
127 int64 pending_changes) { 126 int64 pending_changes) {
128 DCHECK_GE(pending_changes, 0); 127 DCHECK_GE(pending_changes, 0);
129 int64 old_pending_changes = pending_changes_; 128 int64 old_pending_changes = pending_changes_;
130 pending_changes_ = pending_changes; 129 pending_changes_ = pending_changes;
131 if (old_pending_changes != pending_changes) { 130 if (old_pending_changes != pending_changes) {
132 if (pending_changes == 0) 131 if (pending_changes == 0)
133 sync_service()->OnSyncIdle(); 132 client_->OnSyncIdle();
134 util::Log(logging::LOG_VERBOSE, FROM_HERE, 133 util::Log(logging::LOG_VERBOSE, FROM_HERE,
135 "[%s] pending_changes updated: %" PRId64, 134 "[%s] pending_changes updated: %" PRId64,
136 name_.c_str(), pending_changes); 135 name_.c_str(), pending_changes);
137 } 136 }
138 Schedule(); 137 Schedule();
139 } 138 }
140 139
140 SyncFileSystemService* SyncProcessRunner::GetSyncService() {
141 return client_->GetSyncService();
142 }
143
141 SyncServiceState SyncProcessRunner::GetServiceState() { 144 SyncServiceState SyncProcessRunner::GetServiceState() {
142 return sync_service()->GetSyncServiceState(); 145 return client_->GetSyncServiceState();
143 } 146 }
144 147
145 void SyncProcessRunner::Finished(const base::TimeTicks& start_time, 148 void SyncProcessRunner::Finished(const base::TimeTicks& start_time,
146 SyncStatusCode status) { 149 SyncStatusCode status) {
147 DCHECK_LT(0, running_tasks_); 150 DCHECK_LT(0, running_tasks_);
148 DCHECK_LE(running_tasks_, max_parallel_task_); 151 DCHECK_LE(running_tasks_, max_parallel_task_);
149 --running_tasks_; 152 --running_tasks_;
150 util::Log(logging::LOG_VERBOSE, FROM_HERE, 153 util::Log(logging::LOG_VERBOSE, FROM_HERE,
151 "[%s] * Finished (elapsed: %" PRId64 " sec)", 154 "[%s] * Finished (elapsed: %" PRId64 " sec)",
152 name_.c_str(), 155 name_.c_str(),
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 name_.c_str(), time_to_next.InSeconds()); 200 name_.c_str(), time_to_next.InSeconds());
198 } 201 }
199 current_delay_ = delay; 202 current_delay_ = delay;
200 203
201 timer_helper_->Start( 204 timer_helper_->Start(
202 FROM_HERE, time_to_next, 205 FROM_HERE, time_to_next,
203 base::Bind(&SyncProcessRunner::Run, base::Unretained(this))); 206 base::Bind(&SyncProcessRunner::Run, base::Unretained(this)));
204 } 207 }
205 208
206 } // namespace sync_file_system 209 } // namespace sync_file_system
OLDNEW
« no previous file with comments | « chrome/browser/sync_file_system/sync_process_runner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698