OLD | NEW |
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 "chrome/browser/geolocation/chrome_access_token_store.h" | 5 #include "chrome/browser/geolocation/chrome_access_token_store.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 // Loads access tokens and other necessary data on the UI thread, and | 40 // Loads access tokens and other necessary data on the UI thread, and |
41 // calls back to the originator on the originating thread. | 41 // calls back to the originator on the originating thread. |
42 class TokenLoadingJob : public base::RefCountedThreadSafe<TokenLoadingJob> { | 42 class TokenLoadingJob : public base::RefCountedThreadSafe<TokenLoadingJob> { |
43 public: | 43 public: |
44 explicit TokenLoadingJob( | 44 explicit TokenLoadingJob( |
45 const AccessTokenStore::LoadAccessTokensCallback& callback) | 45 const AccessTokenStore::LoadAccessTokensCallback& callback) |
46 : callback_(callback), system_request_context_(NULL) {} | 46 : callback_(callback), system_request_context_(NULL) {} |
47 | 47 |
48 void Run() { | 48 void Run() { |
49 BrowserThread::PostTaskAndReply( | 49 BrowserThread::PostTaskAndReply( |
50 BrowserThread::UI, | 50 BrowserThread::UI, FROM_HERE, |
51 FROM_HERE, | 51 base::BindOnce(&TokenLoadingJob::PerformWorkOnUIThread, this), |
52 base::Bind(&TokenLoadingJob::PerformWorkOnUIThread, this), | 52 base::BindOnce(&TokenLoadingJob::RespondOnOriginatingThread, this)); |
53 base::Bind(&TokenLoadingJob::RespondOnOriginatingThread, this)); | |
54 } | 53 } |
55 | 54 |
56 private: | 55 private: |
57 friend class base::RefCountedThreadSafe<TokenLoadingJob>; | 56 friend class base::RefCountedThreadSafe<TokenLoadingJob>; |
58 | 57 |
59 ~TokenLoadingJob() {} | 58 ~TokenLoadingJob() {} |
60 | 59 |
61 void PerformWorkOnUIThread() { | 60 void PerformWorkOnUIThread() { |
62 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 61 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
63 DictionaryPrefUpdate update(g_browser_process->local_state(), | 62 DictionaryPrefUpdate update(g_browser_process->local_state(), |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 base::DictionaryValue* access_token_dictionary = update.Get(); | 119 base::DictionaryValue* access_token_dictionary = update.Get(); |
121 access_token_dictionary->SetWithoutPathExpansion(server_url.spec(), | 120 access_token_dictionary->SetWithoutPathExpansion(server_url.spec(), |
122 new base::Value(token)); | 121 new base::Value(token)); |
123 } | 122 } |
124 | 123 |
125 void ChromeAccessTokenStore::SaveAccessToken( | 124 void ChromeAccessTokenStore::SaveAccessToken( |
126 const GURL& server_url, | 125 const GURL& server_url, |
127 const base::string16& access_token) { | 126 const base::string16& access_token) { |
128 BrowserThread::PostTask( | 127 BrowserThread::PostTask( |
129 BrowserThread::UI, FROM_HERE, | 128 BrowserThread::UI, FROM_HERE, |
130 base::Bind(&SetAccessTokenOnUIThread, server_url, access_token)); | 129 base::BindOnce(&SetAccessTokenOnUIThread, server_url, access_token)); |
131 } | 130 } |
OLD | NEW |