| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_KEYED_SERVICE_IOS_BROWSER_STATE_HELPER_H_ | 5 #ifndef COMPONENTS_KEYED_SERVICE_IOS_BROWSER_STATE_HELPER_H_ |
| 6 #define COMPONENTS_KEYED_SERVICE_IOS_BROWSER_STATE_HELPER_H_ | 6 #define COMPONENTS_KEYED_SERVICE_IOS_BROWSER_STATE_HELPER_H_ |
| 7 | 7 |
| 8 namespace base { | 8 namespace base { |
| 9 class SupportsUserData; | 9 class SupportsUserData; |
| 10 } | 10 } |
| 11 | 11 |
| 12 namespace web { | 12 namespace web { |
| 13 class BrowserState; | 13 class BrowserState; |
| 14 } | 14 } |
| 15 | 15 |
| 16 // TODO(sdefresne): remove this file and all usage of the methods once iOS code | 16 // TODO(ios): remove this file and all usage of the methods once iOS code only |
| 17 // only use BrowserStateKeyedServiceFactory, http://crbug.com/419366 | 17 // use BrowserStateKeyedServiceFactory, http://crbug.com/478763 |
| 18 | 18 |
| 19 // |BrowserStateFromContextFn| converts from a base::SupportsUserData as passed | 19 // Typedef for a function converting a base::SupportsUserData to the underlying |
| 20 // to a (Refcounted)?BrowserStateKeyedServiceFactory to a web::BrowserState. | 20 // web::BrowserState. |
| 21 using BrowserStateFromContextFn = | 21 using UnderlyingContextFromContextFn = |
| 22 web::BrowserState* (*)(base::SupportsUserData*); | 22 web::BrowserState* (*)(base::SupportsUserData*); |
| 23 | 23 |
| 24 // Registers an helper function to convert a |context| to a web::BrowserState | 24 // Registers an |helper| that allows the embedder to control how the underlying |
| 25 // to allow the embedder to overrides how the BSKSF does the conversion. | 25 // web::BrowserState is obtained from a base::SupportsUserData. |
| 26 void SetBrowserStateFromContextHelper(BrowserStateFromContextFn helper); | 26 void SetUnderlyingContextFromContextHelper( |
| 27 UnderlyingContextFromContextFn helper); |
| 27 | 28 |
| 28 // Converts a |context| to a web::BrowserState using the helper registered by | 29 // Returns the underlying web::BrowserState that corresponds to |context| using |
| 29 // the embedder if any. Usage is restricted to //components/keyed_service/ios. | 30 // the helper registered via SetUnderlyingContextFromContextHelper(). |
| 30 web::BrowserState* BrowserStateFromContext(base::SupportsUserData* context); | 31 web::BrowserState* UnderlyingContextFromContext( |
| 32 base::SupportsUserData* context); |
| 33 |
| 34 // Typedef for a function converting a web::BrowserState to the original |
| 35 // base::SupportsUserData. |
| 36 using OriginalContextFromContextFn = |
| 37 base::SupportsUserData* (*)(web::BrowserState*); |
| 38 |
| 39 // Registers an |helper| that allows the embedder to control how the original |
| 40 // base::SupportsUserData is obtained from a web::BrowserState. |
| 41 void SetOriginalContextFromContextHelper(OriginalContextFromContextFn helper); |
| 42 |
| 43 // Returns the original base::SupportsUserData that corresponds to |context| |
| 44 // using the helper registered via SetOriginalContextFromContextHelper(). |
| 45 base::SupportsUserData* OriginalContextFromContext( |
| 46 base::SupportsUserData* context); |
| 31 | 47 |
| 32 #endif // COMPONENTS_KEYED_SERVICE_IOS_BROWSER_STATE_HELPER_H_ | 48 #endif // COMPONENTS_KEYED_SERVICE_IOS_BROWSER_STATE_HELPER_H_ |
| OLD | NEW |