OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "sync/engine/sync_session_job.h" | 5 #include "sync/engine/sync_session_job.h" |
6 #include "sync/internal_api/public/sessions/model_neutral_state.h" | 6 #include "sync/internal_api/public/sessions/model_neutral_state.h" |
7 | 7 |
8 namespace syncer { | 8 namespace syncer { |
9 | 9 |
10 SyncSessionJob::~SyncSessionJob() { | 10 SyncSessionJob::~SyncSessionJob() { |
11 if (destruction_observer_) | 11 if (destruction_observer_) |
12 destruction_observer_->OnJobDestroyed(this); | 12 destruction_observer_->OnJobDestroyed(this); |
13 } | 13 } |
14 | 14 |
15 SyncSessionJob::SyncSessionJob( | 15 SyncSessionJob::SyncSessionJob( |
16 Purpose purpose, | 16 Purpose purpose, |
17 base::TimeTicks start, | 17 base::TimeTicks start, |
18 scoped_ptr<sessions::SyncSession> session, | 18 scoped_ptr<sessions::SyncSession> session, |
19 const ConfigurationParams& config_params) | 19 const ConfigurationParams& config_params) |
20 : purpose_(purpose), | 20 : purpose_(purpose), |
21 scheduled_start_(start), | 21 scheduled_start_(start), |
22 session_(session.Pass()), | 22 session_(session.Pass()), |
23 is_canary_(false), | |
24 config_params_(config_params), | 23 config_params_(config_params), |
25 finished_(NOT_FINISHED) { | 24 finished_(NOT_FINISHED) { |
26 } | 25 } |
27 | 26 |
28 void SyncSessionJob::set_destruction_observer( | 27 void SyncSessionJob::set_destruction_observer( |
29 const base::WeakPtr<DestructionObserver>& destruction_observer) { | 28 const base::WeakPtr<DestructionObserver>& destruction_observer) { |
30 destruction_observer_ = destruction_observer; | 29 destruction_observer_ = destruction_observer; |
31 } | 30 } |
32 | 31 |
33 #define ENUM_CASE(x) case x: return #x; break; | 32 #define ENUM_CASE(x) case x: return #x; break; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 purpose_, scheduled_start_, CloneSession().Pass(), | 96 purpose_, scheduled_start_, CloneSession().Pass(), |
98 config_params_)); | 97 config_params_)); |
99 } | 98 } |
100 | 99 |
101 scoped_ptr<sessions::SyncSession> SyncSessionJob::CloneSession() const { | 100 scoped_ptr<sessions::SyncSession> SyncSessionJob::CloneSession() const { |
102 return scoped_ptr<sessions::SyncSession>( | 101 return scoped_ptr<sessions::SyncSession>( |
103 new sessions::SyncSession(session_->context(), | 102 new sessions::SyncSession(session_->context(), |
104 session_->delegate(), session_->source())); | 103 session_->delegate(), session_->source())); |
105 } | 104 } |
106 | 105 |
107 bool SyncSessionJob::is_canary() const { | |
108 return is_canary_; | |
109 } | |
110 | |
111 SyncSessionJob::Purpose SyncSessionJob::purpose() const { | 106 SyncSessionJob::Purpose SyncSessionJob::purpose() const { |
112 return purpose_; | 107 return purpose_; |
113 } | 108 } |
114 | 109 |
115 base::TimeTicks SyncSessionJob::scheduled_start() const { | 110 base::TimeTicks SyncSessionJob::scheduled_start() const { |
116 return scheduled_start_; | 111 return scheduled_start_; |
117 } | 112 } |
118 | 113 |
119 void SyncSessionJob::set_scheduled_start(base::TimeTicks start) { | 114 void SyncSessionJob::set_scheduled_start(base::TimeTicks start) { |
120 scheduled_start_ = start; | 115 scheduled_start_ = start; |
121 }; | 116 }; |
122 | 117 |
123 const sessions::SyncSession* SyncSessionJob::session() const { | 118 const sessions::SyncSession* SyncSessionJob::session() const { |
124 return session_.get(); | 119 return session_.get(); |
125 } | 120 } |
126 | 121 |
127 sessions::SyncSession* SyncSessionJob::mutable_session() { | 122 sessions::SyncSession* SyncSessionJob::mutable_session() { |
128 return session_.get(); | 123 return session_.get(); |
129 } | 124 } |
130 | 125 |
131 ConfigurationParams SyncSessionJob::config_params() const { | 126 ConfigurationParams SyncSessionJob::config_params() const { |
132 return config_params_; | 127 return config_params_; |
133 } | 128 } |
134 | 129 |
135 void SyncSessionJob::GrantCanaryPrivilege() { | |
136 DCHECK_EQ(finished_, NOT_FINISHED); | |
137 DVLOG(2) << "Granting canary priviliege to " << session_.get(); | |
138 is_canary_ = true; | |
139 } | |
140 | |
141 SyncerStep SyncSessionJob::start_step() const { | 130 SyncerStep SyncSessionJob::start_step() const { |
142 SyncerStep start, end; | 131 SyncerStep start, end; |
143 GetSyncerStepsForPurpose(purpose_, &start, &end); | 132 GetSyncerStepsForPurpose(purpose_, &start, &end); |
144 return start; | 133 return start; |
145 } | 134 } |
146 | 135 |
147 SyncerStep SyncSessionJob::end_step() const { | 136 SyncerStep SyncSessionJob::end_step() const { |
148 SyncerStep start, end; | 137 SyncerStep start, end; |
149 GetSyncerStepsForPurpose(purpose_, &start, &end); | 138 GetSyncerStepsForPurpose(purpose_, &start, &end); |
150 return end; | 139 return end; |
(...skipping 15 matching lines...) Expand all Loading... |
166 return; | 155 return; |
167 default: | 156 default: |
168 NOTREACHED(); | 157 NOTREACHED(); |
169 *start = SYNCER_END; | 158 *start = SYNCER_END; |
170 *end = SYNCER_END; | 159 *end = SYNCER_END; |
171 return; | 160 return; |
172 } | 161 } |
173 } | 162 } |
174 | 163 |
175 } // namespace syncer | 164 } // namespace syncer |
OLD | NEW |