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

Side by Side Diff: ios/net/http_cache_helper.cc

Issue 1861593005: Convert //ios from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase? 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
« no previous file with comments | « ios/net/crn_http_protocol_handler.mm ('k') | ios/net/http_response_headers_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ios/net/http_cache_helper.h" 5 #include "ios/net/http_cache_helper.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 12 matching lines...) Expand all
23 namespace { 23 namespace {
24 24
25 // Posts |callback| on |task_runner|. 25 // Posts |callback| on |task_runner|.
26 void PostCallback(const scoped_refptr<base::TaskRunner>& task_runner, 26 void PostCallback(const scoped_refptr<base::TaskRunner>& task_runner,
27 const net::CompletionCallback& callback, 27 const net::CompletionCallback& callback,
28 int error) { 28 int error) {
29 task_runner->PostTask(FROM_HERE, base::Bind(callback, error)); 29 task_runner->PostTask(FROM_HERE, base::Bind(callback, error));
30 } 30 }
31 31
32 // Clears the disk_cache::Backend on the IO thread and deletes |backend|. 32 // Clears the disk_cache::Backend on the IO thread and deletes |backend|.
33 void DoomHttpCache(scoped_ptr<disk_cache::Backend*> backend, 33 void DoomHttpCache(std::unique_ptr<disk_cache::Backend*> backend,
34 const scoped_refptr<base::TaskRunner>& client_task_runner, 34 const scoped_refptr<base::TaskRunner>& client_task_runner,
35 const net::CompletionCallback& callback, 35 const net::CompletionCallback& callback,
36 int error) { 36 int error) {
37 // |*backend| may be null in case of error. 37 // |*backend| may be null in case of error.
38 if (*backend) { 38 if (*backend) {
39 (*backend)->DoomAllEntries( 39 (*backend)->DoomAllEntries(
40 base::Bind(&PostCallback, client_task_runner, callback)); 40 base::Bind(&PostCallback, client_task_runner, callback));
41 } else { 41 } else {
42 client_task_runner->PostTask(FROM_HERE, base::Bind(callback, error)); 42 client_task_runner->PostTask(FROM_HERE, base::Bind(callback, error));
43 } 43 }
(...skipping 15 matching lines...) Expand all
59 59
60 // Clear SDCH dictionary state. 60 // Clear SDCH dictionary state.
61 net::SdchManager* sdch_manager = 61 net::SdchManager* sdch_manager =
62 getter->GetURLRequestContext()->sdch_manager(); 62 getter->GetURLRequestContext()->sdch_manager();
63 // The test is probably overkill, since chrome should always have an 63 // The test is probably overkill, since chrome should always have an
64 // SdchManager. But in general the URLRequestContext is *not* 64 // SdchManager. But in general the URLRequestContext is *not*
65 // guaranteed to have an SdchManager, so checking is wise. 65 // guaranteed to have an SdchManager, so checking is wise.
66 if (sdch_manager) 66 if (sdch_manager)
67 sdch_manager->ClearData(); 67 sdch_manager->ClearData();
68 68
69 scoped_ptr<disk_cache::Backend*> backend(new disk_cache::Backend*(nullptr)); 69 std::unique_ptr<disk_cache::Backend*> backend(
70 new disk_cache::Backend*(nullptr));
70 disk_cache::Backend** backend_ptr = backend.get(); 71 disk_cache::Backend** backend_ptr = backend.get();
71 net::CompletionCallback doom_callback = 72 net::CompletionCallback doom_callback =
72 base::Bind(&DoomHttpCache, base::Passed(std::move(backend)), 73 base::Bind(&DoomHttpCache, base::Passed(std::move(backend)),
73 client_task_runner, callback); 74 client_task_runner, callback);
74 75
75 int rv = http_cache->GetBackend(backend_ptr, doom_callback); 76 int rv = http_cache->GetBackend(backend_ptr, doom_callback);
76 77
77 if (rv != net::ERR_IO_PENDING) { 78 if (rv != net::ERR_IO_PENDING) {
78 // GetBackend doesn't call the callback if it completes synchronously, so 79 // GetBackend doesn't call the callback if it completes synchronously, so
79 // call it directly here. 80 // call it directly here.
80 doom_callback.Run(rv); 81 doom_callback.Run(rv);
81 } 82 }
82 } 83 }
83 84
84 } // namespace 85 } // namespace
85 86
86 namespace net { 87 namespace net {
87 88
88 void ClearHttpCache(const scoped_refptr<net::URLRequestContextGetter>& getter, 89 void ClearHttpCache(const scoped_refptr<net::URLRequestContextGetter>& getter,
89 const scoped_refptr<base::TaskRunner>& network_task_runner, 90 const scoped_refptr<base::TaskRunner>& network_task_runner,
90 const net::CompletionCallback& callback) { 91 const net::CompletionCallback& callback) {
91 network_task_runner->PostTask( 92 network_task_runner->PostTask(
92 FROM_HERE, base::Bind(&ClearHttpCacheOnIOThread, getter, 93 FROM_HERE, base::Bind(&ClearHttpCacheOnIOThread, getter,
93 base::ThreadTaskRunnerHandle::Get(), callback)); 94 base::ThreadTaskRunnerHandle::Get(), callback));
94 } 95 }
95 96
96 } // namespace net 97 } // namespace net
OLDNEW
« no previous file with comments | « ios/net/crn_http_protocol_handler.mm ('k') | ios/net/http_response_headers_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698