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

Unified Diff: ios/public/provider/web/web_state_user_data.h

Issue 777183002: Upstream iOS web API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years 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
« no previous file with comments | « ios/public/provider/web/web_state.h ('k') | ios/web/public/navigation_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/public/provider/web/web_state_user_data.h
diff --git a/ios/public/provider/web/web_state_user_data.h b/ios/public/provider/web/web_state_user_data.h
deleted file mode 100644
index a326d08210919fd2b76bedaeb185dcef80182a96..0000000000000000000000000000000000000000
--- a/ios/public/provider/web/web_state_user_data.h
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef IOS_PUBLIC_PROVIDER_WEB_WEB_STATE_USER_DATA_H_
-#define IOS_PUBLIC_PROVIDER_WEB_WEB_STATE_USER_DATA_H_
-
-#include "base/supports_user_data.h"
-#include "ios/public/provider/web/web_state.h"
-
-namespace ios {
-
-// A base class for classes attached to, and scoped to, the lifetime of a
-// WebState. For example:
-//
-// --- in foo.h ---
-// class Foo : public ios::WebStateUserData<Foo> {
-// public:
-// virtual ~Foo();
-// // ... more public stuff here ...
-// private:
-// explicit Foo(ios::WebState* web_state);
-// friend class ios::WebStateUserData<Foo>;
-// // ... more private stuff here ...
-// }
-// --- in foo.cc ---
-// DEFINE_WEB_CONTENTS_USER_DATA_KEY(Foo);
-//
-template <typename T>
-class WebStateUserData : public base::SupportsUserData::Data {
- public:
- // Creates an object of type T, and attaches it to the specified WebState.
- // If an instance is already attached, does nothing.
- static void CreateForWebState(WebState* web_state) {
- if (!FromWebState(web_state))
- web_state->SetUserData(UserDataKey(), new T(web_state));
- }
-
- // Retrieves the instance of type T that was attached to the specified
- // WebState (via CreateForWebState above) and returns it. If no instance
- // of the type was attached, returns NULL.
- static T* FromWebState(WebState* web_state) {
- return static_cast<T*>(web_state->GetUserData(UserDataKey()));
- }
- static const T* FromWebState(const WebState* web_state) {
- return static_cast<const T*>(web_state->GetUserData(UserDataKey()));
- }
-
- protected:
- static inline void* UserDataKey() {
- return &kLocatorKey;
- }
-
- private:
- // The user data key.
- static int kLocatorKey;
-};
-
-// The macro to define the locator key. This key should be defined in the .cc
-// file of the derived class.
-//
-// The "= 0" is surprising, but is required to effect a definition rather than
-// a declaration. Without it, this would be merely a declaration of a template
-// specialization. (C++98: 14.7.3.15; C++11: 14.7.3.13)
-//
-#define DEFINE_WEB_STATE_USER_DATA_KEY(TYPE) \
-template<> \
-int ios::WebStateUserData<TYPE>::kLocatorKey = 0
-
-} // namespace ios
-
-#endif // IOS_PUBLIC_PROVIDER_WEB_WEB_STATE_USER_DATA_H_
« no previous file with comments | « ios/public/provider/web/web_state.h ('k') | ios/web/public/navigation_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698