| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #import "base/mac/bind_objc_block.h" | 8 #import "base/mac/bind_objc_block.h" |
| 9 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 scoped_refptr<net::URLRequestContextGetter> _requestContextGetter; | 106 scoped_refptr<net::URLRequestContextGetter> _requestContextGetter; |
| 107 } | 107 } |
| 108 | 108 |
| 109 + (void)enableConsistencyCheck { | 109 + (void)enableConsistencyCheck { |
| 110 #if !defined(NDEBUG) | 110 #if !defined(NDEBUG) |
| 111 g_consistency_check_enabled = YES; | 111 g_consistency_check_enabled = YES; |
| 112 #endif | 112 #endif |
| 113 } | 113 } |
| 114 | 114 |
| 115 // Overrides default designated initializer. | 115 // Overrides default designated initializer. |
| 116 - (instancetype)init { | |
| 117 NOTREACHED(); | |
| 118 return nil; | |
| 119 } | |
| 120 | |
| 121 - (instancetype)initWithAppId:(NSString*)appId | 116 - (instancetype)initWithAppId:(NSString*)appId |
| 122 version:(NSString*)appVersion | 117 version:(NSString*)appVersion |
| 123 plist:(NSString*)plistName { | 118 plist:(NSString*)plistName { |
| 124 self = [super init]; | 119 self = [super init]; |
| 125 if (self) { | 120 if (self) { |
| 126 _updatableResource.reset([self newResource:plistName]); | 121 _updatableResource.reset([self newResource:plistName]); |
| 127 // UpdatableResourceBridge initializes the appId to what is in the | 122 // UpdatableResourceBridge initializes the appId to what is in the |
| 128 // application bundle. The following overrides that with either the |appId| | 123 // application bundle. The following overrides that with either the |appId| |
| 129 // passed in or a default based on experimental settings if |appId| is nil. | 124 // passed in or a default based on experimental settings if |appId| is nil. |
| 130 if (!appId) | 125 if (!appId) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 150 name:notificationName | 145 name:notificationName |
| 151 object:[_updatableResource descriptor]]; | 146 object:[_updatableResource descriptor]]; |
| 152 | 147 |
| 153 #if !defined(NDEBUG) | 148 #if !defined(NDEBUG) |
| 154 [self scheduleConsistencyCheck]; | 149 [self scheduleConsistencyCheck]; |
| 155 #endif | 150 #endif |
| 156 } | 151 } |
| 157 return self; | 152 return self; |
| 158 } | 153 } |
| 159 | 154 |
| 155 - (instancetype)init { |
| 156 NOTREACHED(); |
| 157 return nil; |
| 158 } |
| 159 |
| 160 - (void)dealloc { | 160 - (void)dealloc { |
| 161 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 161 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| 162 #if !defined(NDEBUG) | 162 #if !defined(NDEBUG) |
| 163 [self cancelConsistencyCheck]; | 163 [self cancelConsistencyCheck]; |
| 164 #endif | 164 #endif |
| 165 [super dealloc]; | 165 [super dealloc]; |
| 166 } | 166 } |
| 167 | 167 |
| 168 - (void)startUpdate:(net::URLRequestContextGetter*)requestContextGetter { | 168 - (void)startUpdate:(net::URLRequestContextGetter*)requestContextGetter { |
| 169 #if !defined(NDEBUG) | 169 #if !defined(NDEBUG) |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 return; | 257 return; |
| 258 if (!_configFetcher) { | 258 if (!_configFetcher) { |
| 259 _configFetcher.reset( | 259 _configFetcher.reset( |
| 260 new ConfigFetcher(self, [_updatableResource descriptor])); | 260 new ConfigFetcher(self, [_updatableResource descriptor])); |
| 261 } | 261 } |
| 262 GURL url = net::GURLWithNSURL([[_updatableResource descriptor] updateURL]); | 262 GURL url = net::GURLWithNSURL([[_updatableResource descriptor] updateURL]); |
| 263 _configFetcher->Fetch(url, _requestContextGetter.get()); | 263 _configFetcher->Fetch(url, _requestContextGetter.get()); |
| 264 } | 264 } |
| 265 | 265 |
| 266 @end | 266 @end |
| OLD | NEW |