Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ppapi / proxy / locking_resource_releaser.h
blobd390ac4426ed4222b36e3fa2d951379bf6196ea6
1 // Copyright (c) 2013 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.
5 #ifndef PPAPI_PROXY_LOCKING_RESOURCE_RELEASER_H_
6 #define PPAPI_PROXY_LOCKING_RESOURCE_RELEASER_H_
8 #include "ppapi/shared_impl/ppapi_globals.h"
9 #include "ppapi/shared_impl/proxy_lock.h"
10 #include "ppapi/shared_impl/resource_tracker.h"
12 namespace ppapi {
13 namespace proxy {
15 // LockingResourceReleaser is a simple RAII class for releasing a resource at
16 // the end of scope. This acquires the ProxyLock before releasing the resource.
17 // It is for use in unit tests. Most proxy or implementation code should use
18 // ScopedPPResource instead. Unit tests sometimes can't use ScopedPPResource
19 // because it asserts that the ProxyLock is already held.
20 class LockingResourceReleaser {
21 public:
22 explicit LockingResourceReleaser(PP_Resource resource)
23 : resource_(resource) {
25 ~LockingResourceReleaser() {
26 ProxyAutoLock lock;
27 PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(resource_);
30 PP_Resource get() { return resource_; }
32 private:
33 PP_Resource resource_;
35 DISALLOW_COPY_AND_ASSIGN(LockingResourceReleaser);
38 } // namespace proxy
39 } // namespace ppapi
41 #endif // PPAPI_PROXY_LOCKING_RESOURCE_RELEASER_H_