OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef PPAPI_SHARED_IMPL_RESOURCE_TRACKER_H_ | 5 #ifndef PPAPI_SHARED_IMPL_RESOURCE_TRACKER_H_ |
6 #define PPAPI_SHARED_IMPL_RESOURCE_TRACKER_H_ | 6 #define PPAPI_SHARED_IMPL_RESOURCE_TRACKER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/hash_tables.h" | 11 #include "base/hash_tables.h" |
12 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/threading/thread_checker.h" | |
15 #include "base/threading/thread_checker_impl.h" | |
14 #include "ppapi/c/pp_instance.h" | 16 #include "ppapi/c/pp_instance.h" |
15 #include "ppapi/c/pp_resource.h" | 17 #include "ppapi/c/pp_resource.h" |
16 #include "ppapi/shared_impl/ppapi_shared_export.h" | 18 #include "ppapi/shared_impl/ppapi_shared_export.h" |
17 | 19 |
18 namespace ppapi { | 20 namespace ppapi { |
19 | 21 |
20 class Resource; | 22 class Resource; |
21 | 23 |
22 class PPAPI_SHARED_EXPORT ResourceTracker { | 24 class PPAPI_SHARED_EXPORT ResourceTracker { |
23 public: | 25 public: |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 // | 91 // |
90 // A resource will be in this list as long as the object is alive. | 92 // A resource will be in this list as long as the object is alive. |
91 typedef std::pair<Resource*, int> ResourceAndRefCount; | 93 typedef std::pair<Resource*, int> ResourceAndRefCount; |
92 typedef base::hash_map<PP_Resource, ResourceAndRefCount> ResourceMap; | 94 typedef base::hash_map<PP_Resource, ResourceAndRefCount> ResourceMap; |
93 ResourceMap live_resources_; | 95 ResourceMap live_resources_; |
94 | 96 |
95 int32 last_resource_value_; | 97 int32 last_resource_value_; |
96 | 98 |
97 base::WeakPtrFactory<ResourceTracker> weak_ptr_factory_; | 99 base::WeakPtrFactory<ResourceTracker> weak_ptr_factory_; |
98 | 100 |
101 // TODO(raymes): We won't be able to do thread checks once pepper calls are | |
102 // allowed off of the main thread. | |
dmichael (off chromium)
2012/09/06 02:57:26
I would rephrase that to "We won't need to do thre
raymes
2012/09/06 16:23:59
Done.
| |
103 // See http://code.google.com/p/chromium/issues/detail?id=92909. | |
104 #ifdef ENABLE_PEPPER_THREADING | |
105 base::ThreadCheckerDoNothing thread_checker_; | |
106 #else | |
107 // TODO(raymes): We've seen plugins (Flash) creating resources from random | |
108 // threads. Let's always crash for now in this case. Once we have a handle | |
109 // over how common this is, we can change ThreadCheckerImpl->ThreadChecker | |
110 // so that we only crash in debug mode. See | |
111 // https://code.google.com/p/chromium/issues/detail?id=146415. | |
112 base::ThreadCheckerImpl thread_checker_; | |
113 #endif | |
114 | |
99 DISALLOW_COPY_AND_ASSIGN(ResourceTracker); | 115 DISALLOW_COPY_AND_ASSIGN(ResourceTracker); |
100 }; | 116 }; |
101 | 117 |
102 } // namespace ppapi | 118 } // namespace ppapi |
103 | 119 |
104 #endif // PPAPI_SHARED_IMPL_RESOURCE_TRACKER_H_ | 120 #endif // PPAPI_SHARED_IMPL_RESOURCE_TRACKER_H_ |
OLD | NEW |