Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / browser / geolocation / fake_access_token_store.cc
blob9e8704a07923bb7d226364b4f8114b36820c1301
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/browser/geolocation/fake_access_token_store.h"
7 #include "base/bind.h"
8 #include "base/location.h"
9 #include "base/logging.h"
10 #include "base/thread_task_runner_handle.h"
12 using testing::_;
13 using testing::Invoke;
15 namespace content {
17 FakeAccessTokenStore::FakeAccessTokenStore() : originating_task_runner_(NULL) {
18 ON_CALL(*this, LoadAccessTokens(_))
19 .WillByDefault(Invoke(this,
20 &FakeAccessTokenStore::DefaultLoadAccessTokens));
21 ON_CALL(*this, SaveAccessToken(_, _))
22 .WillByDefault(Invoke(this,
23 &FakeAccessTokenStore::DefaultSaveAccessToken));
26 void FakeAccessTokenStore::NotifyDelegateTokensLoaded() {
27 DCHECK(originating_task_runner_);
28 if (!originating_task_runner_->BelongsToCurrentThread()) {
29 originating_task_runner_->PostTask(
30 FROM_HERE,
31 base::Bind(&FakeAccessTokenStore::NotifyDelegateTokensLoaded, this));
32 return;
35 net::URLRequestContextGetter* context_getter = NULL;
36 callback_.Run(access_token_set_, context_getter);
39 void FakeAccessTokenStore::DefaultLoadAccessTokens(
40 const LoadAccessTokensCallbackType& callback) {
41 originating_task_runner_ = base::ThreadTaskRunnerHandle::Get().get();
42 callback_ = callback;
45 void FakeAccessTokenStore::DefaultSaveAccessToken(
46 const GURL& server_url, const base::string16& access_token) {
47 DCHECK(server_url.is_valid());
48 access_token_set_[server_url] = access_token;
51 FakeAccessTokenStore::~FakeAccessTokenStore() {}
53 } // namespace content