OLD | NEW |
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 #include "sync/sessions/sync_session.h" | 5 #include "sync/sessions/sync_session.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 new FakeModelWorker(GROUP_PASSIVE)); | 44 new FakeModelWorker(GROUP_PASSIVE)); |
45 scoped_refptr<ModelSafeWorker> ui_worker( | 45 scoped_refptr<ModelSafeWorker> ui_worker( |
46 new FakeModelWorker(GROUP_UI)); | 46 new FakeModelWorker(GROUP_UI)); |
47 scoped_refptr<ModelSafeWorker> db_worker( | 47 scoped_refptr<ModelSafeWorker> db_worker( |
48 new FakeModelWorker(GROUP_DB)); | 48 new FakeModelWorker(GROUP_DB)); |
49 workers_.clear(); | 49 workers_.clear(); |
50 workers_.push_back(passive_worker); | 50 workers_.push_back(passive_worker); |
51 workers_.push_back(ui_worker); | 51 workers_.push_back(ui_worker); |
52 workers_.push_back(db_worker); | 52 workers_.push_back(db_worker); |
53 | 53 |
54 std::vector<ModelSafeWorker*> workers; | |
55 GetWorkers(&workers); | |
56 | |
57 context_.reset( | 54 context_.reset( |
58 new SyncSessionContext( | 55 new SyncSessionContext( |
59 NULL, | 56 NULL, |
60 NULL, | 57 NULL, |
61 workers, | 58 workers_, |
62 extensions_activity_.get(), | 59 extensions_activity_.get(), |
63 std::vector<SyncEngineEventListener*>(), | 60 std::vector<SyncEngineEventListener*>(), |
64 NULL, | 61 NULL, |
65 NULL, | 62 NULL, |
66 true, // enable keystore encryption | 63 true, // enable keystore encryption |
67 false, // force enable pre-commit GU avoidance experiment | 64 false, // force enable pre-commit GU avoidance experiment |
68 "fake_invalidator_client_id")); | 65 "fake_invalidator_client_id")); |
69 context_->set_routing_info(routes_); | 66 context_->set_routing_info(routes_); |
70 | 67 |
71 session_.reset(MakeSession()); | 68 session_.reset(MakeSession()); |
(...skipping 30 matching lines...) Expand all Loading... |
102 virtual void OnReceivedClientInvalidationHintBufferSize( | 99 virtual void OnReceivedClientInvalidationHintBufferSize( |
103 int size) OVERRIDE { | 100 int size) OVERRIDE { |
104 FailControllerInvocationIfDisabled( | 101 FailControllerInvocationIfDisabled( |
105 "OnReceivedClientInvalidationHintBufferSize"); | 102 "OnReceivedClientInvalidationHintBufferSize"); |
106 } | 103 } |
107 virtual void OnSyncProtocolError( | 104 virtual void OnSyncProtocolError( |
108 const sessions::SyncSessionSnapshot& snapshot) OVERRIDE { | 105 const sessions::SyncSessionSnapshot& snapshot) OVERRIDE { |
109 FailControllerInvocationIfDisabled("SyncProtocolError"); | 106 FailControllerInvocationIfDisabled("SyncProtocolError"); |
110 } | 107 } |
111 | 108 |
112 void GetWorkers(std::vector<ModelSafeWorker*>* out) const { | |
113 out->clear(); | |
114 for (std::vector<scoped_refptr<ModelSafeWorker> >::const_iterator it = | |
115 workers_.begin(); it != workers_.end(); ++it) { | |
116 out->push_back(it->get()); | |
117 } | |
118 } | |
119 void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) const { | 109 void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) const { |
120 *out = routes_; | 110 *out = routes_; |
121 } | 111 } |
122 | 112 |
123 StatusController* status() { return session_->mutable_status_controller(); } | 113 StatusController* status() { return session_->mutable_status_controller(); } |
124 protected: | 114 protected: |
125 void FailControllerInvocationIfDisabled(const std::string& msg) { | 115 void FailControllerInvocationIfDisabled(const std::string& msg) { |
126 if (!controller_invocations_allowed_) | 116 if (!controller_invocations_allowed_) |
127 FAIL() << msg; | 117 FAIL() << msg; |
128 } | 118 } |
(...skipping 12 matching lines...) Expand all Loading... |
141 scoped_ptr<SyncSession> session_; | 131 scoped_ptr<SyncSession> session_; |
142 scoped_ptr<SyncSessionContext> context_; | 132 scoped_ptr<SyncSessionContext> context_; |
143 std::vector<scoped_refptr<ModelSafeWorker> > workers_; | 133 std::vector<scoped_refptr<ModelSafeWorker> > workers_; |
144 ModelSafeRoutingInfo routes_; | 134 ModelSafeRoutingInfo routes_; |
145 scoped_refptr<ExtensionsActivity> extensions_activity_; | 135 scoped_refptr<ExtensionsActivity> extensions_activity_; |
146 }; | 136 }; |
147 | 137 |
148 } // namespace | 138 } // namespace |
149 } // namespace sessions | 139 } // namespace sessions |
150 } // namespace syncer | 140 } // namespace syncer |
OLD | NEW |