Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Side by Side Diff: android_webview/browser/net/token_binding_manager.cc

Issue 1852513003: Convert //android_webview to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git is hard Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "android_webview/browser/net/token_binding_manager.h" 5 #include "android_webview/browser/net/token_binding_manager.h"
6 6
7 #include "android_webview/browser/aw_browser_context.h" 7 #include "android_webview/browser/aw_browser_context.h"
8 #include "content/public/browser/browser_thread.h" 8 #include "content/public/browser/browser_thread.h"
9 #include "net/ssl/channel_id_service.h" 9 #include "net/ssl/channel_id_service.h"
10 #include "net/ssl/channel_id_store.h" 10 #include "net/ssl/channel_id_store.h"
11 #include "net/url_request/url_request_context.h" 11 #include "net/url_request/url_request_context.h"
12 #include "net/url_request/url_request_context_getter.h" 12 #include "net/url_request/url_request_context_getter.h"
13 13
14 namespace android_webview { 14 namespace android_webview {
15 15
16 using content::BrowserThread; 16 using content::BrowserThread;
17 using net::ChannelIDService; 17 using net::ChannelIDService;
18 using net::ChannelIDStore; 18 using net::ChannelIDStore;
19 19
20 namespace { 20 namespace {
21 21
22 void CompletionCallback(TokenBindingManager::KeyReadyCallback callback, 22 void CompletionCallback(TokenBindingManager::KeyReadyCallback callback,
23 ChannelIDService::Request* request, 23 ChannelIDService::Request* request,
24 scoped_ptr<crypto::ECPrivateKey>* key, 24 std::unique_ptr<crypto::ECPrivateKey>* key,
25 int status) { 25 int status) {
26 BrowserThread::PostTask( 26 BrowserThread::PostTask(
27 BrowserThread::UI, FROM_HERE, 27 BrowserThread::UI, FROM_HERE,
28 base::Bind(callback, status, base::Owned(key->release()))); 28 base::Bind(callback, status, base::Owned(key->release())));
29 } 29 }
30 30
31 void DeletionCompleteCallback( 31 void DeletionCompleteCallback(
32 TokenBindingManager::DeletionCompleteCallback callback) { 32 TokenBindingManager::DeletionCompleteCallback callback) {
33 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); 33 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback);
34 } 34 }
35 35
36 void GetKeyImpl(const std::string& host, 36 void GetKeyImpl(const std::string& host,
37 TokenBindingManager::KeyReadyCallback callback, 37 TokenBindingManager::KeyReadyCallback callback,
38 scoped_refptr<net::URLRequestContextGetter> context_getter) { 38 scoped_refptr<net::URLRequestContextGetter> context_getter) {
39 ChannelIDService* service = 39 ChannelIDService* service =
40 context_getter->GetURLRequestContext()->channel_id_service(); 40 context_getter->GetURLRequestContext()->channel_id_service();
41 ChannelIDService::Request* request = new ChannelIDService::Request(); 41 ChannelIDService::Request* request = new ChannelIDService::Request();
42 scoped_ptr<crypto::ECPrivateKey>* key = 42 std::unique_ptr<crypto::ECPrivateKey>* key =
43 new scoped_ptr<crypto::ECPrivateKey>(); 43 new std::unique_ptr<crypto::ECPrivateKey>();
44 // The request will own the callback if the call to service returns 44 // The request will own the callback if the call to service returns
45 // PENDING. The request releases the ownership before calling the callback. 45 // PENDING. The request releases the ownership before calling the callback.
46 net::CompletionCallback completion_callback = base::Bind( 46 net::CompletionCallback completion_callback = base::Bind(
47 &CompletionCallback, callback, base::Owned(request), base::Owned(key)); 47 &CompletionCallback, callback, base::Owned(request), base::Owned(key));
48 int status = 48 int status =
49 service->GetOrCreateChannelID(host, key, completion_callback, request); 49 service->GetOrCreateChannelID(host, key, completion_callback, request);
50 if (status == net::ERR_IO_PENDING) { 50 if (status == net::ERR_IO_PENDING) {
51 // The operation is pending, callback will be called async. 51 // The operation is pending, callback will be called async.
52 return; 52 return;
53 } 53 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 void TokenBindingManager::DeleteAllKeys(DeletionCompleteCallback callback) { 102 void TokenBindingManager::DeleteAllKeys(DeletionCompleteCallback callback) {
103 scoped_refptr<net::URLRequestContextGetter> context_getter = 103 scoped_refptr<net::URLRequestContextGetter> context_getter =
104 AwBrowserContext::GetDefault()->GetRequestContext(); 104 AwBrowserContext::GetDefault()->GetRequestContext();
105 BrowserThread::PostTask( 105 BrowserThread::PostTask(
106 BrowserThread::IO, FROM_HERE, 106 BrowserThread::IO, FROM_HERE,
107 base::Bind(&DeleteKeyImpl, "", callback, context_getter, true)); 107 base::Bind(&DeleteKeyImpl, "", callback, context_getter, true));
108 } 108 }
109 109
110 } // namespace android_webview 110 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698