OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #import "ios/chrome/browser/updatable_config/updatable_config_base.h" | 5 #import "ios/chrome/browser/updatable_config/updatable_config_base.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
| 9 #include <memory> |
| 10 |
9 #include "base/logging.h" | 11 #include "base/logging.h" |
10 #import "base/mac/bind_objc_block.h" | 12 #import "base/mac/bind_objc_block.h" |
11 #include "base/mac/scoped_nsobject.h" | 13 #include "base/mac/scoped_nsobject.h" |
12 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | |
14 #import "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 15 #import "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
15 #import "ios/public/provider/chrome/browser/updatable_resource_provider.h" | 16 #import "ios/public/provider/chrome/browser/updatable_resource_provider.h" |
16 #include "ios/web/public/web_thread.h" | 17 #include "ios/web/public/web_thread.h" |
17 #import "net/base/mac/url_conversions.h" | 18 #import "net/base/mac/url_conversions.h" |
18 #include "net/http/http_status_code.h" | 19 #include "net/http/http_status_code.h" |
19 #include "net/url_request/url_fetcher.h" | 20 #include "net/url_request/url_fetcher.h" |
20 #include "net/url_request/url_fetcher_delegate.h" | 21 #include "net/url_request/url_fetcher_delegate.h" |
21 #include "net/url_request/url_request_context.h" | 22 #include "net/url_request/url_request_context.h" |
22 #include "net/url_request/url_request_context_getter.h" | 23 #include "net/url_request/url_request_context_getter.h" |
23 #include "url/gurl.h" | 24 #include "url/gurl.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 dispatch_time(DISPATCH_TIME_NOW, kPeriodicCheckInNanoseconds), | 91 dispatch_time(DISPATCH_TIME_NOW, kPeriodicCheckInNanoseconds), |
91 dispatch_get_main_queue(), ^{ | 92 dispatch_get_main_queue(), ^{ |
92 [owner_ checkUpdate]; | 93 [owner_ checkUpdate]; |
93 }); | 94 }); |
94 })); | 95 })); |
95 }; | 96 }; |
96 | 97 |
97 private: | 98 private: |
98 UpdatableConfigBase* owner_; | 99 UpdatableConfigBase* owner_; |
99 id<UpdatableResourceDescriptorBridge> descriptor_; | 100 id<UpdatableResourceDescriptorBridge> descriptor_; |
100 scoped_ptr<net::URLFetcher> fetcher_; | 101 std::unique_ptr<net::URLFetcher> fetcher_; |
101 }; | 102 }; |
102 | 103 |
103 } // namespace | 104 } // namespace |
104 | 105 |
105 @implementation UpdatableConfigBase { | 106 @implementation UpdatableConfigBase { |
106 base::scoped_nsprotocol<id<UpdatableResourceBridge>> _updatableResource; | 107 base::scoped_nsprotocol<id<UpdatableResourceBridge>> _updatableResource; |
107 scoped_ptr<ConfigFetcher> _configFetcher; | 108 std::unique_ptr<ConfigFetcher> _configFetcher; |
108 scoped_refptr<net::URLRequestContextGetter> _requestContextGetter; | 109 scoped_refptr<net::URLRequestContextGetter> _requestContextGetter; |
109 } | 110 } |
110 | 111 |
111 + (void)enableConsistencyCheck { | 112 + (void)enableConsistencyCheck { |
112 #if !defined(NDEBUG) | 113 #if !defined(NDEBUG) |
113 g_consistency_check_enabled = YES; | 114 g_consistency_check_enabled = YES; |
114 #endif | 115 #endif |
115 } | 116 } |
116 | 117 |
117 // Overrides default designated initializer. | 118 // Overrides default designated initializer. |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 return; | 263 return; |
263 if (!_configFetcher) { | 264 if (!_configFetcher) { |
264 _configFetcher.reset( | 265 _configFetcher.reset( |
265 new ConfigFetcher(self, [_updatableResource descriptor])); | 266 new ConfigFetcher(self, [_updatableResource descriptor])); |
266 } | 267 } |
267 GURL url = net::GURLWithNSURL([[_updatableResource descriptor] updateURL]); | 268 GURL url = net::GURLWithNSURL([[_updatableResource descriptor] updateURL]); |
268 _configFetcher->Fetch(url, _requestContextGetter.get()); | 269 _configFetcher->Fetch(url, _requestContextGetter.get()); |
269 } | 270 } |
270 | 271 |
271 @end | 272 @end |
OLD | NEW |