| 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 "chromecast/browser/geolocation/cast_access_token_store.h" | 5 #include "chromecast/browser/geolocation/cast_access_token_store.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "chromecast/browser/cast_browser_context.h" | 8 #include "chromecast/browser/cast_browser_context.h" |
| 9 #include "chromecast/browser/cast_content_browser_client.h" | 9 #include "chromecast/browser/cast_content_browser_client.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| 11 #include "content/public/browser/storage_partition.h" | |
| 12 #include "content/public/common/content_client.h" | 11 #include "content/public/common/content_client.h" |
| 13 | 12 |
| 14 namespace chromecast { | 13 namespace chromecast { |
| 15 namespace shell { | 14 namespace shell { |
| 16 | 15 |
| 17 CastAccessTokenStore::CastAccessTokenStore( | 16 CastAccessTokenStore::CastAccessTokenStore( |
| 18 content::BrowserContext* browser_context) | 17 content::BrowserContext* browser_context) |
| 19 : browser_context_(browser_context) { | 18 : browser_context_(browser_context) { |
| 20 } | 19 } |
| 21 | 20 |
| 22 CastAccessTokenStore::~CastAccessTokenStore() { | 21 CastAccessTokenStore::~CastAccessTokenStore() { |
| 23 } | 22 } |
| 24 | 23 |
| 25 void CastAccessTokenStore::GetRequestContextGetterOnUIThread() { | 24 void CastAccessTokenStore::GetRequestContextGetterOnUIThread() { |
| 26 request_context_ = content::BrowserContext::GetDefaultStoragePartition( | 25 request_context_ = browser_context_->GetRequestContext(); |
| 27 browser_context_)->GetURLRequestContext(); | |
| 28 } | 26 } |
| 29 | 27 |
| 30 void CastAccessTokenStore::RespondOnOriginatingThread() { | 28 void CastAccessTokenStore::RespondOnOriginatingThread() { |
| 31 base::ResetAndReturn(&callback_).Run(access_token_map_, request_context_); | 29 base::ResetAndReturn(&callback_).Run(access_token_map_, request_context_); |
| 32 } | 30 } |
| 33 | 31 |
| 34 void CastAccessTokenStore::LoadAccessTokens( | 32 void CastAccessTokenStore::LoadAccessTokens( |
| 35 const LoadAccessTokensCallback& callback) { | 33 const LoadAccessTokensCallback& callback) { |
| 36 callback_ = callback; | 34 callback_ = callback; |
| 37 content::BrowserThread::PostTaskAndReply( | 35 content::BrowserThread::PostTaskAndReply( |
| 38 content::BrowserThread::UI, | 36 content::BrowserThread::UI, |
| 39 FROM_HERE, | 37 FROM_HERE, |
| 40 base::Bind(&CastAccessTokenStore::GetRequestContextGetterOnUIThread, | 38 base::Bind(&CastAccessTokenStore::GetRequestContextGetterOnUIThread, |
| 41 this), | 39 this), |
| 42 base::Bind(&CastAccessTokenStore::RespondOnOriginatingThread, this)); | 40 base::Bind(&CastAccessTokenStore::RespondOnOriginatingThread, this)); |
| 43 } | 41 } |
| 44 | 42 |
| 45 void CastAccessTokenStore::SaveAccessToken( | 43 void CastAccessTokenStore::SaveAccessToken( |
| 46 const GURL& server_url, const base::string16& access_token) { | 44 const GURL& server_url, const base::string16& access_token) { |
| 47 if (access_token_map_[server_url] != access_token) { | 45 if (access_token_map_[server_url] != access_token) { |
| 48 access_token_map_[server_url] = access_token; | 46 access_token_map_[server_url] = access_token; |
| 49 } | 47 } |
| 50 } | 48 } |
| 51 | 49 |
| 52 } // namespace shell | 50 } // namespace shell |
| 53 } // namespace chromecast | 51 } // namespace chromecast |
| OLD | NEW |