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/installation_notifier.h" | 5 #import "ios/chrome/browser/installation_notifier.h" |
6 | 6 |
| 7 #import <UIKit/UIKit.h> |
7 #include <stdint.h> | 8 #include <stdint.h> |
8 #import <UIKit/UIKit.h> | 9 |
| 10 #include <memory> |
9 | 11 |
10 #include "base/ios/weak_nsobject.h" | 12 #include "base/ios/weak_nsobject.h" |
11 #include "base/logging.h" | 13 #include "base/logging.h" |
12 #include "base/mac/scoped_nsobject.h" | 14 #include "base/mac/scoped_nsobject.h" |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
15 #include "ios/web/public/web_thread.h" | 16 #include "ios/web/public/web_thread.h" |
16 #include "net/base/backoff_entry.h" | 17 #include "net/base/backoff_entry.h" |
17 #include "url/gurl.h" | 18 #include "url/gurl.h" |
18 | 19 |
19 namespace { | 20 namespace { |
20 const net::BackoffEntry::Policy kPollingBackoffPolicy = { | 21 const net::BackoffEntry::Policy kPollingBackoffPolicy = { |
21 0, // Number of errors to ignore. | 22 0, // Number of errors to ignore. |
22 1 * 1000, // Initial delay in milliseconds. | 23 1 * 1000, // Initial delay in milliseconds. |
23 1.5, // Multiply factor. | 24 1.5, // Multiply factor. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 56 |
56 @interface InstallationNotifier (Testing) | 57 @interface InstallationNotifier (Testing) |
57 // Sets the dispatcher. | 58 // Sets the dispatcher. |
58 - (void)setDispatcher:(id<DispatcherProtocol>)dispatcher; | 59 - (void)setDispatcher:(id<DispatcherProtocol>)dispatcher; |
59 // Sets the UIApplication used to determine if a scheme can be opened by an | 60 // Sets the UIApplication used to determine if a scheme can be opened by an |
60 // application. | 61 // application. |
61 - (void)setSharedApplication:(UIApplication*)sharedApplication; | 62 - (void)setSharedApplication:(UIApplication*)sharedApplication; |
62 @end | 63 @end |
63 | 64 |
64 @implementation InstallationNotifier { | 65 @implementation InstallationNotifier { |
65 scoped_ptr<net::BackoffEntry> _backoffEntry; | 66 std::unique_ptr<net::BackoffEntry> _backoffEntry; |
66 base::scoped_nsprotocol<id<DispatcherProtocol>> _dispatcher; | 67 base::scoped_nsprotocol<id<DispatcherProtocol>> _dispatcher; |
67 // Dictionary mapping URL schemes to mutable sets of observers. | 68 // Dictionary mapping URL schemes to mutable sets of observers. |
68 base::scoped_nsobject<NSMutableDictionary> _installedAppObservers; | 69 base::scoped_nsobject<NSMutableDictionary> _installedAppObservers; |
69 NSNotificationCenter* _notificationCenter; // Weak. | 70 NSNotificationCenter* _notificationCenter; // Weak. |
70 | 71 |
71 // This object can be a fake application in unittests. | 72 // This object can be a fake application in unittests. |
72 UIApplication* sharedApplication_; // Weak. | 73 UIApplication* sharedApplication_; // Weak. |
73 } | 74 } |
74 | 75 |
75 @synthesize lastCreatedBlockId = lastCreatedBlockId_; | 76 @synthesize lastCreatedBlockId = lastCreatedBlockId_; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 } | 216 } |
216 | 217 |
217 - (void)setSharedApplication:(id)sharedApplication { | 218 - (void)setSharedApplication:(id)sharedApplication { |
218 // Verify that the test application object responds to all the selectors that | 219 // Verify that the test application object responds to all the selectors that |
219 // will be called on it. | 220 // will be called on it. |
220 CHECK([sharedApplication respondsToSelector:@selector(canOpenURL:)]); | 221 CHECK([sharedApplication respondsToSelector:@selector(canOpenURL:)]); |
221 sharedApplication_ = (UIApplication*)sharedApplication; | 222 sharedApplication_ = (UIApplication*)sharedApplication; |
222 } | 223 } |
223 | 224 |
224 @end | 225 @end |
OLD | NEW |