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 #ifndef CONTENT_TEST_PLUGIN_PLUGIN_NPOBJECT_LIFETIME_TEST_H_ | 5 #ifndef CONTENT_TEST_PLUGIN_PLUGIN_NPOBJECT_LIFETIME_TEST_H_ |
6 #define CONTENT_TEST_PLUGIN_PLUGIN_NPOBJECT_LIFETIME_TEST_H_ | 6 #define CONTENT_TEST_PLUGIN_PLUGIN_NPOBJECT_LIFETIME_TEST_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "content/test/plugin/plugin_test.h" | 10 #include "content/test/plugin/plugin_test.h" |
11 | 11 |
12 namespace NPAPIClient { | 12 namespace NPAPIClient { |
13 | 13 |
14 // The NPObjectLifeTime class tests the case where a plugin has an NPObject | 14 // The NPObjectLifeTime class tests the case where a plugin has an NPObject |
15 // which points to a different plugin instance on a different frame in the | 15 // which points to a different plugin instance on a different frame in the |
16 // page and whether refcounts on this npobject are valid when the source frame | 16 // page and whether refcounts on this npobject are valid when the source frame |
17 // is destroyed. | 17 // is destroyed. |
18 class NPObjectLifetimeTest : public PluginTest { | 18 class NPObjectLifetimeTest : public PluginTest { |
19 public: | 19 public: |
20 // Constructor. | 20 // Constructor. |
21 NPObjectLifetimeTest(NPP id, NPNetscapeFuncs *host_functions); | 21 NPObjectLifetimeTest(NPP id, NPNetscapeFuncs *host_functions); |
22 | 22 |
23 // NPAPI SetWindow handler. | 23 // NPAPI SetWindow handler. |
24 virtual NPError SetWindow(NPWindow* pNPWindow) override; | 24 NPError SetWindow(NPWindow* pNPWindow) override; |
25 | 25 |
26 virtual void URLNotify(const char* url, | 26 void URLNotify(const char* url, NPReason reason, void* data) override; |
27 NPReason reason, | |
28 void* data) override; | |
29 | 27 |
30 protected: | 28 protected: |
31 NPObject* other_plugin_instance_object_; | 29 NPObject* other_plugin_instance_object_; |
32 | 30 |
33 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
34 static void CALLBACK TimerProc(HWND window, UINT message, UINT_PTR timer_id, | 32 static void CALLBACK TimerProc(HWND window, UINT message, UINT_PTR timer_id, |
35 DWORD elapsed_milli_seconds); | 33 DWORD elapsed_milli_seconds); |
36 UINT_PTR timer_id_; | 34 UINT_PTR timer_id_; |
37 #endif | 35 #endif |
38 DISALLOW_IMPLICIT_CONSTRUCTORS(NPObjectLifetimeTest); | 36 DISALLOW_IMPLICIT_CONSTRUCTORS(NPObjectLifetimeTest); |
39 }; | 37 }; |
40 | 38 |
41 // The NPObjectLifetimeTestInstance2 class represents the plugin instance | 39 // The NPObjectLifetimeTestInstance2 class represents the plugin instance |
42 // which is deleted by the NPObjectLifeTime class via a javascript function. | 40 // which is deleted by the NPObjectLifeTime class via a javascript function. |
43 class NPObjectLifetimeTestInstance2 : public PluginTest { | 41 class NPObjectLifetimeTestInstance2 : public PluginTest { |
44 public: | 42 public: |
45 // Constructor. | 43 // Constructor. |
46 NPObjectLifetimeTestInstance2(NPP id, NPNetscapeFuncs *host_functions); | 44 NPObjectLifetimeTestInstance2(NPP id, NPNetscapeFuncs *host_functions); |
47 virtual ~NPObjectLifetimeTestInstance2(); | 45 ~NPObjectLifetimeTestInstance2() override; |
48 | 46 |
49 // NPAPI SetWindow handler. | 47 // NPAPI SetWindow handler. |
50 virtual NPError SetWindow(NPWindow* pNPWindow) override; | 48 NPError SetWindow(NPWindow* pNPWindow) override; |
| 49 |
51 protected: | 50 protected: |
52 static NPObject* plugin_instance_object_; | 51 static NPObject* plugin_instance_object_; |
53 friend class NPObjectLifetimeTest; | 52 friend class NPObjectLifetimeTest; |
54 | 53 |
55 DISALLOW_IMPLICIT_CONSTRUCTORS(NPObjectLifetimeTestInstance2); | 54 DISALLOW_IMPLICIT_CONSTRUCTORS(NPObjectLifetimeTestInstance2); |
56 }; | 55 }; |
57 | 56 |
58 // The NPObjectLifeTime class tests the case where a plugin instance is | 57 // The NPObjectLifeTime class tests the case where a plugin instance is |
59 // destroyed in NPN_Evaluate | 58 // destroyed in NPN_Evaluate |
60 class NPObjectDeletePluginInNPN_Evaluate : public PluginTest { | 59 class NPObjectDeletePluginInNPN_Evaluate : public PluginTest { |
61 public: | 60 public: |
62 // Constructor. | 61 // Constructor. |
63 NPObjectDeletePluginInNPN_Evaluate(NPP id, NPNetscapeFuncs *host_functions); | 62 NPObjectDeletePluginInNPN_Evaluate(NPP id, NPNetscapeFuncs *host_functions); |
64 virtual ~NPObjectDeletePluginInNPN_Evaluate(); | 63 ~NPObjectDeletePluginInNPN_Evaluate() override; |
65 | 64 |
66 // NPAPI SetWindow handler. | 65 // NPAPI SetWindow handler. |
67 virtual NPError SetWindow(NPWindow* pNPWindow) override; | 66 NPError SetWindow(NPWindow* pNPWindow) override; |
68 | 67 |
69 protected: | 68 protected: |
70 NPObject* plugin_instance_object_; | 69 NPObject* plugin_instance_object_; |
71 #if defined(OS_WIN) | 70 #if defined(OS_WIN) |
72 static void CALLBACK TimerProc(HWND window, UINT message, UINT_PTR timer_id, | 71 static void CALLBACK TimerProc(HWND window, UINT message, UINT_PTR timer_id, |
73 DWORD elapsed_milli_seconds); | 72 DWORD elapsed_milli_seconds); |
74 UINT_PTR timer_id_; | 73 UINT_PTR timer_id_; |
75 #endif | 74 #endif |
76 | 75 |
77 private: | 76 private: |
78 static NPObjectDeletePluginInNPN_Evaluate* g_npn_evaluate_test_instance_; | 77 static NPObjectDeletePluginInNPN_Evaluate* g_npn_evaluate_test_instance_; |
79 | 78 |
80 DISALLOW_IMPLICIT_CONSTRUCTORS(NPObjectDeletePluginInNPN_Evaluate); | 79 DISALLOW_IMPLICIT_CONSTRUCTORS(NPObjectDeletePluginInNPN_Evaluate); |
81 }; | 80 }; |
82 | 81 |
83 } // namespace NPAPIClient | 82 } // namespace NPAPIClient |
84 | 83 |
85 #endif // CONTENT_TEST_PLUGIN_PLUGIN_NPOBJECT_LIFETIME_TEST_H_ | 84 #endif // CONTENT_TEST_PLUGIN_PLUGIN_NPOBJECT_LIFETIME_TEST_H_ |
OLD | NEW |