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

Side by Side Diff: ios/chrome/browser/web/dom_altering_lock.h

Issue 927373002: [iOS] Upstream DomAlteringLock. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef IOS_CHROME_BROWSER_WEB_DOM_ALTERING_LOCK_H_
6 #define IOS_CHROME_BROWSER_WEB_DOM_ALTERING_LOCK_H_
7
8 #include "base/ios/block_types.h"
9 #import "base/ios/weak_nsobject.h"
10 #include "ios/web/public/web_state/web_state_user_data.h"
11
12 typedef void (^ProceduralBlockWithBool)(BOOL);
13
14 // This protocol must be implemented by all classes which may alter the DOM
15 // tree of a web page. Before altering the DOM, the class must call
16 // |DOMAlteringLock::AcquireDOMAlteringLock| and can only proceed if the
17 // lock is really acquired.
18 // After restoring the DOM tree, the class must call
19 // |DOMAlteringLock::ReleaseDOMAlteringLock|.
20 @protocol DOMAltering<NSObject>
21
22 // Method called when another class wants to acquire the lock.
23 // Return YES if the class is ready to restore the DOM tree to its initial state
24 // and release the lock. A call to |releaseDOMLockWithCompletionHandler:|
25 // will follow to do the actual cleaning.
26 // Return NO if the class wants to keep an exclusive access to the DOM tree.
27 // Other features must account for the fact that they may not be able to acquire
28 // a lock on the DOM and behave accordingly.
29 - (BOOL)canReleaseDOMLock;
30
31 // Method called when another class wants to acquire the lock.
32 // The class must restore the DOM tree, call
33 // |DOMAlteringLock Release| and then |completionHandler|;
sdefresne 2015/02/17 13:20:55 s/DOMAlteringLock Release/DOMAlteringLock::Release
34 - (void)releaseDOMLockWithCompletionHandler:(ProceduralBlock)completionHandler;
35
36 @end
37
38 class DOMAlteringLock : public web::WebStateUserData<DOMAlteringLock> {
sdefresne 2015/02/17 13:20:55 Can you add a comment that you can Acquire multipl
39 public:
40 DOMAlteringLock(web::WebState* web_state);
41
42 // This method must be called before altering the DOM of the page. This will
43 // ensure that only one class tries to alter the page at a time.
44 // The completion handler is called with YES if the lock was acquired, or NO
45 // if it could not.
46 // This method must be called on the UI thread.
47 void Acquire(id<DOMAltering> feature, ProceduralBlockWithBool lockAction);
48
49 // Releases the lock on the DOM tree.
50 // This method must be called on the UI thread.
51 void Release(id<DOMAltering> feature);
52
53 private:
54 // DOMAltering object currently having the lock.
55 base::WeakNSProtocol<id<DOMAltering>> current_dom_altering_feature_;
56
57 ~DOMAlteringLock() override;
58 };
59
60 #endif // IOS_CHROME_BROWSER_WEB_DOM_ALTERING_LOCK_H_
OLDNEW
« no previous file with comments | « no previous file | ios/chrome/browser/web/dom_altering_lock.mm » ('j') | ios/chrome/browser/web/dom_altering_lock.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698