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
3 // found in the LICENSE file.
5 #ifndef IOS_CHROME_BROWSER_UPDATABLE_CONFIG_UPDATABLE_CONFIG_BASE_H_
6 #define IOS_CHROME_BROWSER_UPDATABLE_CONFIG_UPDATABLE_CONFIG_BASE_H_
8 #import <Foundation/Foundation.h>
11 class URLRequestContextGetter
;
14 @protocol UpdatableResourceBridge
;
16 // Abstract base class for configurations bundled in a .plist file in
17 // application bundle. Configuration is periodically updated by pulling
18 // in a new configuration file from gstatic.com.
19 // DO NOT use this class directly, but instantiate either UpdatableArray
20 // or UpdatableDictionary class instead.
21 // |startUpdate:| must be called for every subclass.
22 @interface UpdatableConfigBase
: NSObject
24 // Initializes a new Updatable Config object using .plist file named |plistName|
25 // which is in the application bundle. |appId| and |appVersion| are used to
26 // derive the URL to update this plist from gstatic.com.
27 // If |appId| is nil, a default value based on the application id from the
28 // application bundle will be provided.
29 // If |appVersion| is nil, a default value based on the application version
30 // number from the application bundle will be provided.
31 - (instancetype
)initWithAppId
:(NSString
*)appId
32 version
:(NSString
*)appVersion
33 plist
:(NSString
*)plistName
;
35 // Starts periodic checks with server for updated version of
36 // configuration plists
37 - (void)startUpdate
:(net::URLRequestContextGetter
*)requestContextGetter
;
39 // Prevents any future update checks, and releases requestContextGetter. Should
40 // be called if the app is going to terminate.
41 - (void)stopUpdateChecks
;
43 // Performs any post-update operations for the updated data to take effect.
44 - (void)resourceDidUpdate
:(NSNotification
*)notification
;
46 // Subclasses must override this method to return a UpdatableResourceBridge
47 // object. The returned object determines whether the resource stored in the
48 // file |resourceName| is of plist, json, or some other data file format.
49 - (id
<UpdatableResourceBridge
>)newResource
:(NSString
*)resourceName
;
51 // Returns the internal resources object. This accessor is intended for
52 // use by subclasses of this class and for unit testing only.
53 // Note that this is really a readonly property for subclasses, but for
54 // unit testing, the ability to set the resource is also needed.
55 @
property(nonatomic
, retain
) id
<UpdatableResourceBridge
> updatableResource
;
57 // Consistency check defaults to NO and is enabled only by Chrome application,
58 // not unit or kif tests.
59 + (void)enableConsistencyCheck
;
63 #endif // IOS_CHROME_BROWSER_UPDATABLE_CONFIG_UPDATABLE_CONFIG_BASE_H_