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

Side by Side Diff: sync/engine/sync_session_job.h

Issue 13422003: sync: Refactor job ownership in SyncScheduler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update comment Created 7 years, 8 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 | « sync/engine/sync_scheduler_whitebox_unittest.cc ('k') | sync/engine/sync_session_job.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 #ifndef SYNC_ENGINE_SYNC_SESSION_JOB_H_ 5 #ifndef SYNC_ENGINE_SYNC_SESSION_JOB_H_
6 #define SYNC_ENGINE_SYNC_SESSION_JOB_H_ 6 #define SYNC_ENGINE_SYNC_SESSION_JOB_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 19 matching lines...) Expand all
30 // during initial sync or reconfiguration. 30 // during initial sync or reconfiguration.
31 CONFIGURATION, 31 CONFIGURATION,
32 }; 32 };
33 33
34 SyncSessionJob(Purpose purpose, 34 SyncSessionJob(Purpose purpose,
35 base::TimeTicks start, 35 base::TimeTicks start,
36 const sessions::SyncSourceInfo& source_info, 36 const sessions::SyncSourceInfo& source_info,
37 const ConfigurationParams& config_params); 37 const ConfigurationParams& config_params);
38 ~SyncSessionJob(); 38 ~SyncSessionJob();
39 39
40 // Returns a new clone of the job, with a cloned SyncSession ready to be
41 // retried / rescheduled.
42 scoped_ptr<SyncSessionJob> Clone() const;
43
44 // Overwrite the sync update source with the most recent and merge the 40 // Overwrite the sync update source with the most recent and merge the
45 // type/state map. 41 // type/state map.
46 void CoalesceSources(const sessions::SyncSourceInfo& source); 42 void CoalesceSources(const sessions::SyncSourceInfo& source);
47 43
48 // Record that the scheduler has deemed the job as finished and give it a 44 // Record that the scheduler has deemed the job as finished and give it a
49 // chance to perform any remaining cleanup and/or notification completion 45 // chance to perform any remaining cleanup and/or notification completion
50 // callback invocations. 46 // callback invocations.
51 // |early_exit| specifies whether the job 1) cycled through all the 47 // |early_exit| specifies whether the job 1) cycled through all the
52 // SyncerSteps it needed, or 2) was pre-empted by the scheduler. 48 // SyncerSteps it needed, or 2) was pre-empted by the scheduler.
53 // Returns true if we completely ran the session without errors. 49 // Returns true if we completely ran the session without errors.
(...skipping 14 matching lines...) Expand all
68 64
69 Purpose purpose() const; 65 Purpose purpose() const;
70 const sessions::SyncSourceInfo& source_info() const; 66 const sessions::SyncSourceInfo& source_info() const;
71 base::TimeTicks scheduled_start() const; 67 base::TimeTicks scheduled_start() const;
72 void set_scheduled_start(base::TimeTicks start); 68 void set_scheduled_start(base::TimeTicks start);
73 SyncerStep start_step() const; 69 SyncerStep start_step() const;
74 SyncerStep end_step() const; 70 SyncerStep end_step() const;
75 ConfigurationParams config_params() const; 71 ConfigurationParams config_params() const;
76 72
77 private: 73 private:
78 // A SyncSessionJob can be in one of these three states, controlled by the
79 // Finish() function, see method comments.
80 enum FinishedState {
81 NOT_FINISHED, // Finish has not been called.
82 EARLY_EXIT, // Finish was called but the job was "preempted",
83 FINISHED // Indicates a "clean" finish operation.
84 };
85
86 const Purpose purpose_; 74 const Purpose purpose_;
87 sessions::SyncSourceInfo source_info_; 75 sessions::SyncSourceInfo source_info_;
88 76
89 base::TimeTicks scheduled_start_; 77 base::TimeTicks scheduled_start_;
90 78
91 // Only used for purpose_ == CONFIGURATION. This, and different Finish() and 79 // Only used for purpose_ == CONFIGURATION. This, and different Finish() and
92 // Succeeded() behavior may be arguments to subclass in the future. 80 // Succeeded() behavior may be arguments to subclass in the future.
93 const ConfigurationParams config_params_; 81 const ConfigurationParams config_params_;
94 82
95 // Set to true if Finish() was called, false otherwise. True implies that
96 // a SyncShare operation took place with |session_| and it cycled through
97 // all requisite steps given |purpose_| without being preempted.
98 FinishedState finished_;
99
100 DISALLOW_COPY_AND_ASSIGN(SyncSessionJob); 83 DISALLOW_COPY_AND_ASSIGN(SyncSessionJob);
101 }; 84 };
102 85
103 } // namespace syncer 86 } // namespace syncer
104 87
105 #endif // SYNC_ENGINE_SYNC_SESSION_JOB_H_ 88 #endif // SYNC_ENGINE_SYNC_SESSION_JOB_H_
OLDNEW
« no previous file with comments | « sync/engine/sync_scheduler_whitebox_unittest.cc ('k') | sync/engine/sync_session_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698