Chromium Code Reviews| Index: cc/output/context_provider.cc |
| diff --git a/cc/output/context_provider.cc b/cc/output/context_provider.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..433568d49d3909b8e0951da0bd9bf3a4acab4dbf |
| --- /dev/null |
| +++ b/cc/output/context_provider.cc |
| @@ -0,0 +1,26 @@ |
| +// Copyright (c) 2016 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. |
| + |
| +#include "cc/output/context_provider.h" |
| + |
| +namespace cc { |
| + |
| +ContextProvider::ScopedContextLock::ScopedContextLock( |
| + ContextProvider* context_provider) |
| + : context_provider_(context_provider), |
| + context_lock_(*context_provider_->GetLock()), |
| + busy_(context_provider_->ContextSupport()->ClientBecameBusy()) { |
| + // Allow current thread to use |context_provider_|. |
| + context_provider_->DetachFromThread(); |
|
danakj
2016/08/23 01:26:24
You don't need to do this before ClientBecameBusy?
ericrk
2016/08/24 18:32:21
The detach/attach is only necessary before access
|
| +} |
| + |
| +ContextProvider::ScopedContextLock::~ScopedContextLock() { |
| + // Let ContextSupport know we are no longer busy. |
| + context_provider_->ContextSupport()->ClientBecameNotBusy(std::move(busy_)); |
| + |
| + // Allow usage by thread for which |context_provider_| is bound to. |
| + context_provider_->DetachFromThread(); |
| +} |
| + |
| +} // namespace cc |