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

Side by Side Diff: chrome/browser/sync/glue/fake_data_type_controller.cc

Issue 10662035: [Sync] Put everything in sync/api into csync namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix comments Created 8 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
OLDNEW
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 "testing/gmock/include/gmock/gmock.h" 5 #include "testing/gmock/include/gmock/gmock.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 7
8 #include "chrome/browser/sync/glue/fake_data_type_controller.h" 8 #include "chrome/browser/sync/glue/fake_data_type_controller.h"
9 9
10 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 10 matching lines...) Expand all
21 21
22 // NOT_RUNNING ->MODEL_LOADED |MODEL_STARTING. 22 // NOT_RUNNING ->MODEL_LOADED |MODEL_STARTING.
23 void FakeDataTypeController::LoadModels( 23 void FakeDataTypeController::LoadModels(
24 const ModelLoadCallback& model_load_callback) { 24 const ModelLoadCallback& model_load_callback) {
25 if (state_ != NOT_RUNNING) { 25 if (state_ != NOT_RUNNING) {
26 ADD_FAILURE(); 26 ADD_FAILURE();
27 return; 27 return;
28 } 28 }
29 29
30 if (model_load_delayed_ == false) { 30 if (model_load_delayed_ == false) {
31 model_load_callback.Run(type(), SyncError()); 31 model_load_callback.Run(type(), csync::SyncError());
32 state_ = MODEL_LOADED; 32 state_ = MODEL_LOADED;
33 } else { 33 } else {
34 model_load_callback_ = model_load_callback; 34 model_load_callback_ = model_load_callback;
35 state_ = MODEL_STARTING; 35 state_ = MODEL_STARTING;
36 } 36 }
37 } 37 }
38 38
39 void FakeDataTypeController::OnModelLoaded() { 39 void FakeDataTypeController::OnModelLoaded() {
40 NOTREACHED(); 40 NOTREACHED();
41 } 41 }
42 42
43 // MODEL_LOADED -> MODEL_STARTING. 43 // MODEL_LOADED -> MODEL_STARTING.
44 void FakeDataTypeController::StartAssociating( 44 void FakeDataTypeController::StartAssociating(
45 const StartCallback& start_callback) { 45 const StartCallback& start_callback) {
46 last_start_callback_ = start_callback; 46 last_start_callback_ = start_callback;
47 state_ = ASSOCIATING; 47 state_ = ASSOCIATING;
48 } 48 }
49 49
50 // MODEL_STARTING | ASSOCIATING -> RUNNING | DISABLED | NOT_RUNNING 50 // MODEL_STARTING | ASSOCIATING -> RUNNING | DISABLED | NOT_RUNNING
51 // (depending on |result|) 51 // (depending on |result|)
52 void FakeDataTypeController::FinishStart(StartResult result) { 52 void FakeDataTypeController::FinishStart(StartResult result) {
53 // We should have a callback from Start(). 53 // We should have a callback from Start().
54 if (last_start_callback_.is_null()) { 54 if (last_start_callback_.is_null()) {
55 ADD_FAILURE(); 55 ADD_FAILURE();
56 return; 56 return;
57 } 57 }
58 58
59 // Set |state_| first below since the callback may call state(). 59 // Set |state_| first below since the callback may call state().
60 SyncError error; 60 csync::SyncError error;
61 if (result <= OK_FIRST_RUN) { 61 if (result <= OK_FIRST_RUN) {
62 state_ = RUNNING; 62 state_ = RUNNING;
63 } else if (result == ASSOCIATION_FAILED) { 63 } else if (result == ASSOCIATION_FAILED) {
64 state_ = DISABLED; 64 state_ = DISABLED;
65 error.Reset(FROM_HERE, "Association failed", type_); 65 error.Reset(FROM_HERE, "Association failed", type_);
66 } else { 66 } else {
67 state_ = NOT_RUNNING; 67 state_ = NOT_RUNNING;
68 error.Reset(FROM_HERE, "Fake error", type_); 68 error.Reset(FROM_HERE, "Fake error", type_);
69 } 69 }
70 last_start_callback_.Run(result, error); 70 last_start_callback_.Run(result, error);
71 last_start_callback_.Reset(); 71 last_start_callback_.Reset();
72 } 72 }
73 73
74 // * -> NOT_RUNNING 74 // * -> NOT_RUNNING
75 void FakeDataTypeController::Stop() { 75 void FakeDataTypeController::Stop() {
76 state_ = NOT_RUNNING; 76 state_ = NOT_RUNNING;
77 // The DTM still expects |last_start_callback_| to be called back. 77 // The DTM still expects |last_start_callback_| to be called back.
78 if (!last_start_callback_.is_null()) { 78 if (!last_start_callback_.is_null()) {
79 SyncError error(FROM_HERE, "Fake error", type_); 79 csync::SyncError error(FROM_HERE, "Fake error", type_);
80 last_start_callback_.Run(ABORTED, error); 80 last_start_callback_.Run(ABORTED, error);
81 } 81 }
82 } 82 }
83 83
84 ModelType FakeDataTypeController::type() const { 84 ModelType FakeDataTypeController::type() const {
85 return type_; 85 return type_;
86 } 86 }
87 87
88 std::string FakeDataTypeController::name() const { 88 std::string FakeDataTypeController::name() const {
89 return ModelTypeToString(type_); 89 return ModelTypeToString(type_);
(...skipping 20 matching lines...) Expand all
110 const std::string& message) { 110 const std::string& message) {
111 ADD_FAILURE() << message; 111 ADD_FAILURE() << message;
112 } 112 }
113 113
114 void FakeDataTypeController::SetDelayModelLoad() { 114 void FakeDataTypeController::SetDelayModelLoad() {
115 model_load_delayed_ = true; 115 model_load_delayed_ = true;
116 } 116 }
117 117
118 void FakeDataTypeController::SimulateModelLoadFinishing() { 118 void FakeDataTypeController::SimulateModelLoadFinishing() {
119 ModelLoadCallback model_load_callback = model_load_callback_; 119 ModelLoadCallback model_load_callback = model_load_callback_;
120 model_load_callback.Run(type(), SyncError()); 120 model_load_callback.Run(type(), csync::SyncError());
121 } 121 }
122 122
123 } // namespace browser_sync 123 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698