146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
546d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)#include "components/invalidation/fake_invalidation_state_tracker.h"
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/bind.h"
82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/callback.h"
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/location.h"
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/task_runner.h"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "testing/gtest/include/gtest/gtest.h"
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace syncer {
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const int64 FakeInvalidationStateTracker::kMinVersion = kint64min;
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)FakeInvalidationStateTracker::FakeInvalidationStateTracker() {}
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)FakeInvalidationStateTracker::~FakeInvalidationStateTracker() {}
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
210529e5d033099cbfc42635f6f6183833b09dff6eBen Murdochvoid FakeInvalidationStateTracker::ClearAndSetNewClientId(
222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const std::string& client_id) {
23c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  Clear();
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  invalidator_client_id_ = client_id;
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)std::string FakeInvalidationStateTracker::GetInvalidatorClientId() const {
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return invalidator_client_id_;
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void FakeInvalidationStateTracker::SetBootstrapData(
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    const std::string& data) {
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bootstrap_data_ = data;
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)std::string FakeInvalidationStateTracker::GetBootstrapData() const {
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return bootstrap_data_;
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
40f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)void FakeInvalidationStateTracker::SetSavedInvalidations(
41f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)    const UnackedInvalidationsMap& states) {
42f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  unacked_invalidations_map_ = states;
43c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}
44c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
45f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)UnackedInvalidationsMap
46f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)FakeInvalidationStateTracker::GetSavedInvalidations() const {
47f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  return unacked_invalidations_map_;
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
50f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)void FakeInvalidationStateTracker::Clear() {
51f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  invalidator_client_id_.clear();
52f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  bootstrap_data_.clear();
532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace syncer
56