| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // TODO: Need mechanism to cleanup the static instance | 5 // TODO: Need mechanism to cleanup the static instance |
| 6 | 6 |
| 7 #ifndef WEBKIT_GLUE_PLUGIN_PLUGIN_HOST_H__ | 7 #ifndef WEBKIT_GLUE_PLUGIN_PLUGIN_HOST_H__ |
| 8 #define WEBKIT_GLUE_PLUGIN_PLUGIN_HOST_H__ | 8 #define WEBKIT_GLUE_PLUGIN_PLUGIN_HOST_H__ |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 #include <map> | |
| 13 | 12 |
| 14 #include "base/ref_counted.h" | 13 #include "base/ref_counted.h" |
| 15 #include "base/gfx/rect.h" | |
| 16 #include "base/task.h" | |
| 17 #include "webkit/glue/plugins/nphostapi.h" | 14 #include "webkit/glue/plugins/nphostapi.h" |
| 18 #include "third_party/npapi/bindings/npapi.h" | 15 #include "third_party/npapi/bindings/npapi.h" |
| 19 | 16 |
| 20 namespace NPAPI | 17 namespace NPAPI |
| 21 { | 18 { |
| 22 class PluginInstance; | 19 class PluginInstance; |
| 23 | 20 |
| 24 // The Plugin Host implements the NPN_xxx functions for NPAPI plugins. | 21 // The Plugin Host implements the NPN_xxx functions for NPAPI plugins. |
| 25 // These are the functions exposed from the Plugin Host for use | 22 // These are the functions exposed from the Plugin Host for use |
| 26 // by the Plugin. | 23 // by the Plugin. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 43 // This function parses it out and adds it to the stream in a WebKit | 40 // This function parses it out and adds it to the stream in a WebKit |
| 44 // style. | 41 // style. |
| 45 static bool SetPostData(const char *buf, | 42 static bool SetPostData(const char *buf, |
| 46 uint32 length, | 43 uint32 length, |
| 47 std::vector<std::string>* names, | 44 std::vector<std::string>* names, |
| 48 std::vector<std::string>* values, | 45 std::vector<std::string>* values, |
| 49 std::vector<char>* body); | 46 std::vector<char>* body); |
| 50 | 47 |
| 51 void PatchNPNetscapeFuncs(NPNetscapeFuncs* overrides); | 48 void PatchNPNetscapeFuncs(NPNetscapeFuncs* overrides); |
| 52 | 49 |
| 53 // Handles invalidateRect requests for windowless plugins. | |
| 54 void InvalidateRect(NPP id, NPRect* invalidRect); | |
| 55 | |
| 56 private: | 50 private: |
| 57 PluginHost(); | 51 PluginHost(); |
| 58 void InitializeHostFuncs(); | 52 void InitializeHostFuncs(); |
| 59 // For certain plugins like flash we need to throttle invalidateRect | |
| 60 // requests as they are made at a high frequency. | |
| 61 void OnInvalidateRect(NPP id, PluginInstance* instance); | |
| 62 | |
| 63 static scoped_refptr<PluginHost> singleton_; | 53 static scoped_refptr<PluginHost> singleton_; |
| 64 NPNetscapeFuncs host_funcs_; | 54 NPNetscapeFuncs host_funcs_; |
| 65 DISALLOW_EVIL_CONSTRUCTORS(PluginHost); | 55 DISALLOW_EVIL_CONSTRUCTORS(PluginHost); |
| 66 | |
| 67 // This structure keeps track of individual plugin instance invalidates. | |
| 68 struct ThrottledInvalidates { | |
| 69 std::vector<gfx::Rect> throttled_invalidates; | |
| 70 }; | |
| 71 | |
| 72 // We need to track throttled invalidate rects on a per plugin instance | |
| 73 // basis. | |
| 74 typedef std::map<NPP, ThrottledInvalidates> InstanceThrottledInvalidatesMap; | |
| 75 InstanceThrottledInvalidatesMap instance_throttled_invalidates_; | |
| 76 | |
| 77 ScopedRunnableMethodFactory<PluginHost> throttle_factory_; | |
| 78 }; | 56 }; |
| 79 | 57 |
| 80 } // namespace NPAPI | 58 } // namespace NPAPI |
| 81 | 59 |
| 82 #endif // WEBKIT_GLUE_PLUGIN_PLUGIN_HOST_H__ | 60 #endif // WEBKIT_GLUE_PLUGIN_PLUGIN_HOST_H__ |
| 83 | 61 |
| OLD | NEW |