OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/cpp/instance.h" | 5 #include "ppapi/cpp/instance.h" |
6 | 6 |
7 #include "ppapi/c/pp_errors.h" | 7 #include "ppapi/c/pp_errors.h" |
8 #include "ppapi/c/ppb_input_event.h" | 8 #include "ppapi/c/ppb_input_event.h" |
9 #include "ppapi/c/ppb_instance.h" | 9 #include "ppapi/c/ppb_instance.h" |
10 #include "ppapi/c/ppb_messaging.h" | 10 #include "ppapi/c/ppb_messaging.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 template <> const char* interface_name<PPB_Messaging>() { | 35 template <> const char* interface_name<PPB_Messaging>() { |
36 return PPB_MESSAGING_INTERFACE; | 36 return PPB_MESSAGING_INTERFACE; |
37 } | 37 } |
38 | 38 |
39 } // namespace | 39 } // namespace |
40 | 40 |
41 Instance::Instance(PP_Instance instance) : pp_instance_(instance) { | 41 Instance::Instance(PP_Instance instance) : pp_instance_(instance) { |
42 } | 42 } |
43 | 43 |
44 Instance::~Instance() { | 44 Instance::~Instance() { |
45 // Ensure that all per-instance objects have been removed. Generally, these | |
46 // objects should have their lifetime scoped to the instance, such as being | |
47 // instance members or even implemented by your instance sub-class directly. | |
48 // | |
49 // If they're not unregistered at this point, they will usually have a | |
50 // dangling reference to the instance, which can cause a crash later. | |
51 PP_DCHECK(interface_name_to_objects_.empty()); | |
52 } | 45 } |
53 | 46 |
54 bool Instance::Init(uint32_t /*argc*/, const char* /*argn*/[], | 47 bool Instance::Init(uint32_t /*argc*/, const char* /*argn*/[], |
55 const char* /*argv*/[]) { | 48 const char* /*argv*/[]) { |
56 return true; | 49 return true; |
57 } | 50 } |
58 | 51 |
59 void Instance::DidChangeView(const View& view) { | 52 void Instance::DidChangeView(const View& view) { |
60 // Call the deprecated version for source backwards-compat. | 53 // Call the deprecated version for source backwards-compat. |
61 DidChangeView(view.GetRect(), view.GetClipRect()); | 54 DidChangeView(view.GetRect(), view.GetClipRect()); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 if (!that) | 167 if (!that) |
175 return NULL; | 168 return NULL; |
176 InterfaceNameToObjectMap::iterator found = | 169 InterfaceNameToObjectMap::iterator found = |
177 that->interface_name_to_objects_.find(interface_name); | 170 that->interface_name_to_objects_.find(interface_name); |
178 if (found == that->interface_name_to_objects_.end()) | 171 if (found == that->interface_name_to_objects_.end()) |
179 return NULL; | 172 return NULL; |
180 return found->second; | 173 return found->second; |
181 } | 174 } |
182 | 175 |
183 } // namespace pp | 176 } // namespace pp |
OLD | NEW |