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

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

Issue 927373002: [iOS] Upstream DomAlteringLock. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor comment change 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
« no previous file with comments | « ios/chrome/browser/web/dom_altering_lock.h ('k') | ios/chrome/ios_chrome.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #import "ios/chrome/browser/web/dom_altering_lock.h"
6
7 #include "base/logging.h"
8 #include "ios/web/public/web_thread.h"
9
10 DEFINE_WEB_STATE_USER_DATA_KEY(DOMAlteringLock);
11
12 DOMAlteringLock::DOMAlteringLock(web::WebState* web_state) {
13 }
14
15 DOMAlteringLock::~DOMAlteringLock() {
16 }
17
18 void DOMAlteringLock::Acquire(id<DOMAltering> feature,
19 ProceduralBlockWithBool lockAction) {
20 DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::UI);
21 if (current_dom_altering_feature_.get() == feature) {
22 lockAction(YES);
23 return;
24 }
25 if (current_dom_altering_feature_) {
26 if (![current_dom_altering_feature_ canReleaseDOMLock]) {
27 lockAction(NO);
28 return;
29 }
30 [current_dom_altering_feature_ releaseDOMLockWithCompletionHandler:^() {
31 DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::UI);
32 DCHECK(current_dom_altering_feature_.get() == nil)
33 << "The lock must be released before calling the completion handler.";
34 current_dom_altering_feature_.reset(feature);
35 lockAction(YES);
36 }];
37 return;
38 }
39 current_dom_altering_feature_.reset(feature);
40 lockAction(YES);
41 }
42
43 // Release the lock on the DOM tree.
44 void DOMAlteringLock::Release(id<DOMAltering> feature) {
45 DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::UI);
46 if (current_dom_altering_feature_.get() == feature)
47 current_dom_altering_feature_.reset();
48 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/web/dom_altering_lock.h ('k') | ios/chrome/ios_chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698