OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <cstddef> | 5 #include <cstddef> |
6 #include <map> | 6 #include <map> |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/single_thread_task_runner.h" |
13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 14 #include "base/thread_task_runner_handle.h" |
14 #include "components/invalidation/fake_invalidation_state_tracker.h" | 15 #include "components/invalidation/fake_invalidation_state_tracker.h" |
15 #include "components/invalidation/invalidation_util.h" | 16 #include "components/invalidation/invalidation_util.h" |
16 #include "components/invalidation/object_id_invalidation_map.h" | 17 #include "components/invalidation/object_id_invalidation_map.h" |
17 #include "components/invalidation/push_client_channel.h" | 18 #include "components/invalidation/push_client_channel.h" |
18 #include "components/invalidation/sync_invalidation_listener.h" | 19 #include "components/invalidation/sync_invalidation_listener.h" |
19 #include "components/invalidation/unacked_invalidation_set_test_util.h" | 20 #include "components/invalidation/unacked_invalidation_set_test_util.h" |
20 #include "google/cacheinvalidation/include/invalidation-client.h" | 21 #include "google/cacheinvalidation/include/invalidation-client.h" |
21 #include "google/cacheinvalidation/include/types.h" | 22 #include "google/cacheinvalidation/include/types.h" |
22 #include "jingle/notifier/listener/fake_push_client.h" | 23 #include "jingle/notifier/listener/fake_push_client.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 // Restart client without re-registering IDs. | 278 // Restart client without re-registering IDs. |
278 void RestartClient() { | 279 void RestartClient() { |
279 StopClient(); | 280 StopClient(); |
280 StartClient(); | 281 StartClient(); |
281 } | 282 } |
282 | 283 |
283 void StartClient() { | 284 void StartClient() { |
284 fake_invalidation_client_ = NULL; | 285 fake_invalidation_client_ = NULL; |
285 listener_.Start( | 286 listener_.Start( |
286 base::Bind(&CreateFakeInvalidationClient, &fake_invalidation_client_), | 287 base::Bind(&CreateFakeInvalidationClient, &fake_invalidation_client_), |
287 kClientId, | 288 kClientId, kClientInfo, kState, fake_tracker_.GetSavedInvalidations(), |
288 kClientInfo, | 289 fake_tracker_.AsWeakPtr(), base::ThreadTaskRunnerHandle::Get(), |
289 kState, | |
290 fake_tracker_.GetSavedInvalidations(), | |
291 fake_tracker_.AsWeakPtr(), | |
292 base::MessageLoopProxy::current(), | |
293 &fake_delegate_); | 290 &fake_delegate_); |
294 DCHECK(fake_invalidation_client_); | 291 DCHECK(fake_invalidation_client_); |
295 } | 292 } |
296 | 293 |
297 void StopClient() { | 294 void StopClient() { |
298 // listener_.StopForTest() stops the invalidation scheduler, which | 295 // listener_.StopForTest() stops the invalidation scheduler, which |
299 // deletes any pending tasks without running them. Some tasks | 296 // deletes any pending tasks without running them. Some tasks |
300 // "run and delete" another task, so they must be run in order to | 297 // "run and delete" another task, so they must be run in order to |
301 // avoid leaking the inner task. listener_.StopForTest() does not | 298 // avoid leaking the inner task. listener_.StopForTest() does not |
302 // schedule any tasks, so it's both necessary and sufficient to | 299 // schedule any tasks, so it's both necessary and sufficient to |
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1104 ids.insert(kExtensionsId_); | 1101 ids.insert(kExtensionsId_); |
1105 listener_.UpdateRegisteredIds(ids); | 1102 listener_.UpdateRegisteredIds(ids); |
1106 | 1103 |
1107 ASSERT_EQ(3U, GetInvalidationCount(kExtensionsId_)); | 1104 ASSERT_EQ(3U, GetInvalidationCount(kExtensionsId_)); |
1108 EXPECT_EQ(30, GetVersion(kExtensionsId_)); | 1105 EXPECT_EQ(30, GetVersion(kExtensionsId_)); |
1109 } | 1106 } |
1110 | 1107 |
1111 } // namespace | 1108 } // namespace |
1112 | 1109 |
1113 } // namespace syncer | 1110 } // namespace syncer |
OLD | NEW |