Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Unified Diff: components/keyed_service/ios/browser_state_helper.cc

Issue 1090373003: Allow cross dependencies between BCKSF and BSKSF (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix dependencies and DCHECK in Get{Original,Underlying}ContextInternal Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/keyed_service/ios/browser_state_helper.cc
diff --git a/components/keyed_service/ios/browser_state_helper.cc b/components/keyed_service/ios/browser_state_helper.cc
index c8e39f8e2257163deeae4b43e5eb1b910fbdf05c..a155b2a26ef07e0ee1a8da763e1727cd8c460f3d 100644
--- a/components/keyed_service/ios/browser_state_helper.cc
+++ b/components/keyed_service/ios/browser_state_helper.cc
@@ -9,7 +9,7 @@
#include "ios/web/public/browser_state.h"
// iOS code is still using BrowserContextKeyedServiceFactory and until the
-// upstreaming is complete (http://crbug.com/419366) there is need to have
+// conversion is complete (http://crbug.com/478763) there is need to have
// mixed dependency between BCKSF and BSKSF.
//
// The implementation has BrowserStateKeyedServiceFactory supporting a
@@ -31,20 +31,40 @@
// to find the associated web::BrowserState (there is a 1:1 mapping).
namespace {
-BrowserStateFromContextFn g_browser_state_from_context = nullptr;
+UnderlyingContextFromContextFn g_underlying_context_from_context = nullptr;
+OriginalContextFromContextFn g_original_context_from_context = nullptr;
} // namespace
-void SetBrowserStateFromContextHelper(BrowserStateFromContextFn helper) {
- g_browser_state_from_context = helper;
+void SetUnderlyingContextFromContextHelper(
+ UnderlyingContextFromContextFn helper) {
+ DCHECK_NE(UnderlyingContextFromContext, helper);
+ g_underlying_context_from_context = helper;
}
-web::BrowserState* BrowserStateFromContext(base::SupportsUserData* context) {
- web::BrowserState* state = nullptr;
+web::BrowserState* UnderlyingContextFromContext(
+ base::SupportsUserData* context) {
+ web::BrowserState* underlying_context = nullptr;
if (context) {
- state = web::BrowserState::FromSupportsUserData(context);
- if (!state && g_browser_state_from_context)
- state = g_browser_state_from_context(context);
- DCHECK(state) << "cannot convert context to web::BrowserState";
+ underlying_context = web::BrowserState::FromSupportsUserData(context);
+ if (!underlying_context && g_underlying_context_from_context)
+ underlying_context = g_underlying_context_from_context(context);
+ DCHECK(underlying_context) << "cannot resolve underlying context";
}
- return state;
+ return underlying_context;
+}
+
+void SetOriginalContextFromContextHelper(OriginalContextFromContextFn helper) {
+ g_original_context_from_context = helper;
+}
+
+base::SupportsUserData* OriginalContextFromContext(
+ base::SupportsUserData* context) {
+ base::SupportsUserData* original_context = context;
+ if (context) {
+ web::BrowserState* browser_state =
+ web::BrowserState::FromSupportsUserData(context);
+ if (browser_state && g_original_context_from_context)
+ original_context = g_original_context_from_context(browser_state);
+ }
+ return original_context;
}

Powered by Google App Engine
This is Rietveld 408576698