OLD | NEW |
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> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 11 #include "base/callback.h" |
10 #include "base/location.h" | 12 #include "base/location.h" |
11 #include "base/task_runner.h" | 13 #include "base/task_runner.h" |
12 #include "net/base/sdch_manager.h" | 14 #include "net/base/sdch_manager.h" |
13 #include "net/disk_cache/disk_cache.h" | 15 #include "net/disk_cache/disk_cache.h" |
14 #include "net/http/http_cache.h" | 16 #include "net/http/http_cache.h" |
15 #include "net/http/http_network_session.h" | 17 #include "net/http/http_network_session.h" |
16 #include "net/http/http_transaction_factory.h" | 18 #include "net/http/http_transaction_factory.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 getter->GetURLRequestContext()->sdch_manager(); | 62 getter->GetURLRequestContext()->sdch_manager(); |
61 // The test is probably overkill, since chrome should always have an | 63 // The test is probably overkill, since chrome should always have an |
62 // SdchManager. But in general the URLRequestContext is *not* | 64 // SdchManager. But in general the URLRequestContext is *not* |
63 // guaranteed to have an SdchManager, so checking is wise. | 65 // guaranteed to have an SdchManager, so checking is wise. |
64 if (sdch_manager) | 66 if (sdch_manager) |
65 sdch_manager->ClearData(); | 67 sdch_manager->ClearData(); |
66 | 68 |
67 scoped_ptr<disk_cache::Backend*> backend(new disk_cache::Backend*(nullptr)); | 69 scoped_ptr<disk_cache::Backend*> backend(new disk_cache::Backend*(nullptr)); |
68 disk_cache::Backend** backend_ptr = backend.get(); | 70 disk_cache::Backend** backend_ptr = backend.get(); |
69 net::CompletionCallback doom_callback = | 71 net::CompletionCallback doom_callback = |
70 base::Bind(&DoomHttpCache, base::Passed(backend.Pass()), | 72 base::Bind(&DoomHttpCache, base::Passed(std::move(backend)), |
71 client_task_runner, callback); | 73 client_task_runner, callback); |
72 | 74 |
73 int rv = http_cache->GetBackend(backend_ptr, doom_callback); | 75 int rv = http_cache->GetBackend(backend_ptr, doom_callback); |
74 | 76 |
75 if (rv != net::ERR_IO_PENDING) { | 77 if (rv != net::ERR_IO_PENDING) { |
76 // GetBackend doesn't call the callback if it completes synchronously, so | 78 // GetBackend doesn't call the callback if it completes synchronously, so |
77 // call it directly here. | 79 // call it directly here. |
78 doom_callback.Run(rv); | 80 doom_callback.Run(rv); |
79 } | 81 } |
80 } | 82 } |
81 | 83 |
82 } // namespace | 84 } // namespace |
83 | 85 |
84 namespace net { | 86 namespace net { |
85 | 87 |
86 void ClearHttpCache(const scoped_refptr<net::URLRequestContextGetter>& getter, | 88 void ClearHttpCache(const scoped_refptr<net::URLRequestContextGetter>& getter, |
87 const scoped_refptr<base::TaskRunner>& network_task_runner, | 89 const scoped_refptr<base::TaskRunner>& network_task_runner, |
88 const net::CompletionCallback& callback) { | 90 const net::CompletionCallback& callback) { |
89 network_task_runner->PostTask( | 91 network_task_runner->PostTask( |
90 FROM_HERE, base::Bind(&ClearHttpCacheOnIOThread, getter, | 92 FROM_HERE, base::Bind(&ClearHttpCacheOnIOThread, getter, |
91 base::ThreadTaskRunnerHandle::Get(), callback)); | 93 base::ThreadTaskRunnerHandle::Get(), callback)); |
92 } | 94 } |
93 | 95 |
94 } // namespace net | 96 } // namespace net |
OLD | NEW |