| 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 #import "ios/chrome/browser/web/dom_altering_lock.h" | 5 #import "ios/chrome/browser/web/dom_altering_lock.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ios/web/public/web_thread.h" | 8 #include "ios/web/public/web_thread.h" |
| 9 | 9 |
| 10 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 11 #error "This file requires ARC support." |
| 12 #endif |
| 13 |
| 10 DEFINE_WEB_STATE_USER_DATA_KEY(DOMAlteringLock); | 14 DEFINE_WEB_STATE_USER_DATA_KEY(DOMAlteringLock); |
| 11 | 15 |
| 12 DOMAlteringLock::DOMAlteringLock(web::WebState* web_state) { | 16 DOMAlteringLock::DOMAlteringLock(web::WebState* web_state) { |
| 13 } | 17 } |
| 14 | 18 |
| 15 DOMAlteringLock::~DOMAlteringLock() { | 19 DOMAlteringLock::~DOMAlteringLock() { |
| 16 } | 20 } |
| 17 | 21 |
| 18 void DOMAlteringLock::Acquire(id<DOMAltering> feature, | 22 void DOMAlteringLock::Acquire(id<DOMAltering> feature, |
| 19 ProceduralBlockWithBool lockAction) { | 23 ProceduralBlockWithBool lockAction) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 39 current_dom_altering_feature_.reset(feature); | 43 current_dom_altering_feature_.reset(feature); |
| 40 lockAction(YES); | 44 lockAction(YES); |
| 41 } | 45 } |
| 42 | 46 |
| 43 // Release the lock on the DOM tree. | 47 // Release the lock on the DOM tree. |
| 44 void DOMAlteringLock::Release(id<DOMAltering> feature) { | 48 void DOMAlteringLock::Release(id<DOMAltering> feature) { |
| 45 DCHECK_CURRENTLY_ON(web::WebThread::UI); | 49 DCHECK_CURRENTLY_ON(web::WebThread::UI); |
| 46 if (current_dom_altering_feature_.get() == feature) | 50 if (current_dom_altering_feature_.get() == feature) |
| 47 current_dom_altering_feature_.reset(); | 51 current_dom_altering_feature_.reset(); |
| 48 } | 52 } |
| OLD | NEW |