| 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 #include "ppapi/shared_impl/resource.h" | 5 #include "ppapi/shared_impl/resource.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ppapi/shared_impl/resource_tracker.h" | 8 #include "ppapi/shared_impl/resource_tracker.h" |
| 9 #include "ppapi/shared_impl/ppapi_globals.h" | 9 #include "ppapi/shared_impl/ppapi_globals.h" |
| 10 | 10 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 // See previous constructor. | 38 // See previous constructor. |
| 39 host_resource_.SetHostResource(host_resource.instance(), pp_resource_); | 39 host_resource_.SetHostResource(host_resource.instance(), pp_resource_); |
| 40 } | 40 } |
| 41 } | 41 } |
| 42 | 42 |
| 43 Resource::Resource(Untracked) { | 43 Resource::Resource(Untracked) { |
| 44 pp_resource_ = PpapiGlobals::Get()->GetResourceTracker()->AddResource(this); | 44 pp_resource_ = PpapiGlobals::Get()->GetResourceTracker()->AddResource(this); |
| 45 } | 45 } |
| 46 | 46 |
| 47 Resource::~Resource() { | 47 Resource::~Resource() { |
| 48 PpapiGlobals::Get()->GetResourceTracker()->RemoveResource(this); | 48 RemoveFromResourceTracker(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 PP_Resource Resource::GetReference() { | 51 PP_Resource Resource::GetReference() { |
| 52 PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(pp_resource()); | 52 PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(pp_resource()); |
| 53 return pp_resource(); | 53 return pp_resource(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void Resource::NotifyLastPluginRefWasDeleted() { | 56 void Resource::NotifyLastPluginRefWasDeleted() { |
| 57 // Notify subclasses. | 57 // Notify subclasses. |
| 58 LastPluginRefWasDeleted(); | 58 LastPluginRefWasDeleted(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 72 void Resource::OnReplyReceived(const proxy::ResourceMessageReplyParams& params, | 72 void Resource::OnReplyReceived(const proxy::ResourceMessageReplyParams& params, |
| 73 const IPC::Message& msg) { | 73 const IPC::Message& msg) { |
| 74 NOTREACHED(); | 74 NOTREACHED(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void Resource::Log(PP_LogLevel level, const std::string& message) { | 77 void Resource::Log(PP_LogLevel level, const std::string& message) { |
| 78 PpapiGlobals::Get()->LogWithSource(pp_instance(), level, std::string(), | 78 PpapiGlobals::Get()->LogWithSource(pp_instance(), level, std::string(), |
| 79 message); | 79 message); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void Resource::RemoveFromResourceTracker() { |
| 83 PpapiGlobals::Get()->GetResourceTracker()->RemoveResource(this); |
| 84 } |
| 85 |
| 82 #define DEFINE_TYPE_GETTER(RESOURCE) \ | 86 #define DEFINE_TYPE_GETTER(RESOURCE) \ |
| 83 thunk::RESOURCE* Resource::As##RESOURCE() { return NULL; } | 87 thunk::RESOURCE* Resource::As##RESOURCE() { return NULL; } |
| 84 FOR_ALL_PPAPI_RESOURCE_APIS(DEFINE_TYPE_GETTER) | 88 FOR_ALL_PPAPI_RESOURCE_APIS(DEFINE_TYPE_GETTER) |
| 85 #undef DEFINE_TYPE_GETTER | 89 #undef DEFINE_TYPE_GETTER |
| 86 | 90 |
| 87 } // namespace ppapi | 91 } // namespace ppapi |
| 88 | 92 |
| OLD | NEW |