Chromium Code Reviews| 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 #ifndef IOS_WEB_CRW_BROWSING_DATA_STORE_H_ | 5 #ifndef IOS_WEB_CRW_BROWSING_DATA_STORE_H_ |
| 6 #define IOS_WEB_CRW_BROWSING_DATA_STORE_H_ | 6 #define IOS_WEB_CRW_BROWSING_DATA_STORE_H_ |
| 7 | 7 |
| 8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
| 9 | 9 |
| 10 #import "base/ios/block_types.h" | 10 #import "base/ios/block_types.h" |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 // The CRWBrowsingDataStore's mode is in the process of becoming either ACTIVE | 30 // The CRWBrowsingDataStore's mode is in the process of becoming either ACTIVE |
| 31 // or INACTIVE. | 31 // or INACTIVE. |
| 32 CHANGING, | 32 CHANGING, |
| 33 // Browsing data is stored in a path unique to the BrowserState and is | 33 // Browsing data is stored in a path unique to the BrowserState and is |
| 34 // currently not being read or written to by web views. | 34 // currently not being read or written to by web views. |
| 35 INACTIVE, | 35 INACTIVE, |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 } // namespace web | 38 } // namespace web |
| 39 | 39 |
| 40 // A CRWBrowsingDataStore represents various types of data that a web view | 40 // A CRWBrowsingDataStore represents various types of data that a web view uses. |
| 41 // (UIWebView and WKWebView) uses. | 41 // All methods must be called on the main thread. |
| 42 // All methods must be called on the UI thread. | |
| 43 @interface CRWBrowsingDataStore : NSObject | 42 @interface CRWBrowsingDataStore : NSObject |
| 44 | 43 |
| 45 // Designated initializer. |browserState| cannot be null. | |
| 46 // The initial mode of the CRWBrowsingDataStore is obtained from the active | |
| 47 // state of the |web::ActiveStateManager| associated with |browserState|. | |
| 48 - (instancetype)initWithBrowserState:(web::BrowserState*)browserState | |
| 49 NS_DESIGNATED_INITIALIZER; | |
| 50 | |
| 51 // The delegate that is consulted when the mode needs to change. | 44 // The delegate that is consulted when the mode needs to change. |
| 52 @property(nonatomic, weak) id<CRWBrowsingDataStoreDelegate> delegate; | 45 @property(nonatomic, weak) id<CRWBrowsingDataStoreDelegate> delegate; |
| 53 | 46 |
| 54 // The mode that the CRWBrowsingDataStore is in. KVO compliant. | 47 // The mode that the CRWBrowsingDataStore is in. KVO compliant. |
| 55 @property(nonatomic, assign, readonly) web::BrowsingDataStoreMode mode; | 48 @property(nonatomic, assign, readonly) web::BrowsingDataStoreMode mode; |
| 56 | 49 |
| 57 // TODO(shreyasv): Verify the preconditions for the following 3 methods when | 50 // A BOOL indicating whether there is still a pending operation that has not |
| 58 // web::WebViewCounter class is implemented. crbug.com/480507 | 51 // finished running. Creating web views with this CRWBrowsingDataStore when |
| 52 // there are pending operations results in undefined behavior. | |
| 53 @property(nonatomic, assign, readonly) BOOL hasPendingOperations; | |
| 54 | |
| 55 // |browserState| cannot be nullptr. The initial mode of the | |
|
Eugene But (OOO till 7-30)
2015/07/09 20:08:08
s/nullptr/null
Because |browserState| can not be
shreyasv1
2015/07/10 17:06:22
Done.
| |
| 56 // CRWBrowsingDataStore is obtained from the active state of the | |
| 57 // |web::ActiveStateManager| associated with |browserState|. | |
| 58 - (instancetype)initWithBrowserState:(web::BrowserState*)browserState | |
| 59 NS_DESIGNATED_INITIALIZER; | |
| 60 - (instancetype)init NS_UNAVAILABLE; | |
| 59 | 61 |
| 60 // Changes the mode to |ACTIVE|. | 62 // Changes the mode to |ACTIVE|. |
| 61 // if there is no delegate present, the default behavior of this method is to | 63 // If there is no delegate present, the default behavior of this method is to |
| 62 // restore browsing data from |browserState|'s stash path to the canonical path | 64 // restore browsing data from |browserState|'s stash path to the canonical path |
| 63 // where web views read/write browsing data to. | 65 // where web views read/write browsing data to. |
| 64 // |completionHandler| is called on the main thread. This block has no return | 66 // |completionHandler| is called on the main thread. This block has no return |
| 65 // value and takes a single BOOL argument that indicates whether or not the | 67 // value and takes a single BOOL argument that indicates whether or not the |
| 66 // the mode was successfully changed to |ACTIVE|. | 68 // the mode was successfully changed to |ACTIVE|. |
| 67 // The mode change to |ACTIVE| can fail if another |makeActive| or | 69 // The mode change to |ACTIVE| can fail if another |makeActive| or |
| 68 // |makeInactive| was enqueued after this call. | 70 // |makeInactive| was enqueued after this call. |
| 69 // Precondition: There must be no web views associated with the BrowserState. | 71 // Precondition: There must be no web views associated with the BrowserState. |
| 70 - (void)makeActiveWithCompletionHandler: | 72 - (void)makeActiveWithCompletionHandler: |
| 71 (void (^)(BOOL success))completionHandler; | 73 (void (^)(BOOL success))completionHandler; |
| 72 | 74 |
| 73 // Changes the mode to |INACTIVE|. | 75 // Changes the mode to |INACTIVE|. |
| 74 // if there is no delegate present, the default behavior of this method is to | 76 // If there is no delegate present, the default behavior of this method is to |
| 75 // value and takes a single BOOL argument that indicates whether or not the | 77 // stash browsing data created by the web view in to the |browserState|'s stash |
| 76 // stash browsing data created by the web view in to |browserState|'s stash | |
| 77 // path. | 78 // path. |
| 78 // |completionHandler| is called on the main thread. This block has no return | 79 // |completionHandler| is called on the main thread. This block has no return |
| 79 // value and takes a single BOOL argument that indicates whether or not the | 80 // value and takes a single BOOL argument that indicates whether or not the |
| 80 // the mode was successfully changed to |INACTIVE|. | 81 // the mode was successfully changed to |INACTIVE|. |
| 81 // The mode change to |ACTIVE| can fail if another |makeActive| or | 82 // The mode change to |INACTIVE| can fail if another |makeActive| or |
| 82 // |makeInactive| was enqueued after this call. | 83 // |makeInactive| was enqueued after this call. |
| 83 // Precondition: There must be no web views associated with the BrowserState. | 84 // Precondition: There must be no web views associated with the BrowserState. |
| 84 - (void)makeInactiveWithCompletionHandler: | 85 - (void)makeInactiveWithCompletionHandler: |
| 85 (void (^)(BOOL success))completionHandler; | 86 (void (^)(BOOL success))completionHandler; |
| 86 | 87 |
| 87 // Removes all browsing data of the provided |browsingDataTypes|. | 88 // Removes all browsing data of the provided |browsingDataTypes|. |
| 88 // |completionHandler| is called on the main thread after the browsing data has | 89 // |completionHandler| is called on the main thread after the browsing data has |
| 89 // been removed. | 90 // been removed. |
| 90 // Precondition: There must be no web views associated with the BrowserState. | 91 // Precondition: There must be no web views associated with the BrowserState. |
| 91 - (void)removeDataOfTypes:(web::BrowsingDataTypes)browsingDataTypes | 92 - (void)removeDataOfTypes:(web::BrowsingDataTypes)browsingDataTypes |
| 92 completionHandler:(ProceduralBlock)completionHandler; | 93 completionHandler:(ProceduralBlock)completionHandler; |
| 93 | 94 |
| 94 // Returns YES if there is still a pending operation that has not finished | |
| 95 // running. Creating web views (UIWebViews and WKWebViews) with this | |
| 96 // CRWBrowsingDataStore when there are pending operations is undefined | |
| 97 // behavior. | |
| 98 @property(nonatomic, assign, readonly) BOOL hasPendingOperations; | |
| 99 | |
| 100 @end | 95 @end |
| 101 | 96 |
| 102 #endif // IOS_WEB_CRW_BROWSING_DATA_STORE_H_ | 97 #endif // IOS_WEB_CRW_BROWSING_DATA_STORE_H_ |
| OLD | NEW |