OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "webkit/glue/plugins/pepper_resource_tracker.h" | 5 #include "webkit/glue/plugins/pepper_resource_tracker.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "third_party/ppapi/c/pp_resource.h" | 10 #include "third_party/ppapi/c/pp_resource.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 void ResourceTracker::DeleteResource(Resource* resource) { | 50 void ResourceTracker::DeleteResource(Resource* resource) { |
51 AutoLock lock(lock_); | 51 AutoLock lock(lock_); |
52 ResourceSet::iterator found = live_resources_.find(resource); | 52 ResourceSet::iterator found = live_resources_.find(resource); |
53 if (found == live_resources_.end()) { | 53 if (found == live_resources_.end()) { |
54 NOTREACHED(); | 54 NOTREACHED(); |
55 return; | 55 return; |
56 } | 56 } |
57 live_resources_.erase(found); | 57 live_resources_.erase(found); |
58 } | 58 } |
59 | 59 |
60 #define GET_AS_TYPE_IMPL(Type) \ | |
61 scoped_refptr<Type> ResourceTracker::GetAs##Type( \ | |
62 PP_Resource res) const { \ | |
63 scoped_refptr<Resource> resource = GetResource(res); \ | |
64 if (!resource.get()) \ | |
65 return scoped_refptr<Type>(); \ | |
66 return scoped_refptr<Type>(resource->As##Type()); \ | |
67 } | |
68 | |
69 GET_AS_TYPE_IMPL(Buffer) | |
70 GET_AS_TYPE_IMPL(DeviceContext2D) | |
71 GET_AS_TYPE_IMPL(DirectoryReader) | |
72 GET_AS_TYPE_IMPL(FileChooser) | |
73 GET_AS_TYPE_IMPL(FileIO) | |
74 GET_AS_TYPE_IMPL(FileRef) | |
75 GET_AS_TYPE_IMPL(ImageData) | |
76 GET_AS_TYPE_IMPL(URLLoader) | |
77 GET_AS_TYPE_IMPL(URLRequestInfo) | |
78 GET_AS_TYPE_IMPL(URLResponseInfo) | |
79 | |
80 } // namespace pepper | 60 } // namespace pepper |
OLD | NEW |