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 #ifndef CHROME_COMMON_CHROME_PLUGIN_UTIL_H__ | 5 #ifndef CHROME_COMMON_CHROME_PLUGIN_UTIL_H__ |
6 #define CHROME_COMMON_CHROME_PLUGIN_UTIL_H__ | 6 #define CHROME_COMMON_CHROME_PLUGIN_UTIL_H__ |
Evan Stade
2009/03/12 22:28:30
single trailing underscore.
| |
7 | 7 |
8 #include <string> | |
9 | |
8 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
9 #include "base/non_thread_safe.h" | 11 #include "base/non_thread_safe.h" |
10 #include "base/ref_counted.h" | 12 #include "base/ref_counted.h" |
11 #include "chrome/common/chrome_plugin_api.h" | 13 #include "chrome/common/chrome_plugin_api.h" |
12 #include "chrome/common/notification_observer.h" | 14 #include "chrome/common/notification_observer.h" |
13 | 15 |
14 class ChromePluginLib; | 16 class ChromePluginLib; |
15 class MessageLoop; | 17 class MessageLoop; |
16 namespace net { | 18 namespace net { |
17 class HttpResponseHeaders; | 19 class HttpResponseHeaders; |
(...skipping 26 matching lines...) Expand all Loading... | |
44 virtual ~PluginHelper(); | 46 virtual ~PluginHelper(); |
45 | 47 |
46 // NotificationObserver | 48 // NotificationObserver |
47 virtual void Observe(NotificationType type, | 49 virtual void Observe(NotificationType type, |
48 const NotificationSource& source, | 50 const NotificationSource& source, |
49 const NotificationDetails& details); | 51 const NotificationDetails& details); |
50 | 52 |
51 protected: | 53 protected: |
52 scoped_refptr<ChromePluginLib> plugin_; | 54 scoped_refptr<ChromePluginLib> plugin_; |
53 | 55 |
54 DISALLOW_EVIL_CONSTRUCTORS(PluginHelper); | 56 DISALLOW_EVIL_CONSTRUCTORS(PluginHelper); |
Evan Stade
2009/03/12 22:28:30
DISALLOW_COPY_AND_ASSIGN
| |
55 }; | 57 }; |
56 | 58 |
57 // A class of utility functions for dealing with request responses. | 59 // A class of utility functions for dealing with request responses. |
58 class PluginResponseUtils { | 60 class PluginResponseUtils { |
59 public: | 61 public: |
60 // Helper to convert request load flags from the plugin API to the net API | 62 // Helper to convert request load flags from the plugin API to the net API |
61 // versions. | 63 // versions. |
62 static uint32 CPLoadFlagsToNetFlags(uint32 flags); | 64 static uint32 CPLoadFlagsToNetFlags(uint32 flags); |
63 | 65 |
64 // Common implementation of a CPR_GetResponseInfo call. | 66 // Common implementation of a CPR_GetResponseInfo call. |
65 static int GetResponseInfo( | 67 static int GetResponseInfo( |
66 const net::HttpResponseHeaders* response_headers, | 68 const net::HttpResponseHeaders* response_headers, |
67 CPResponseInfoType type, void* buf, size_t buf_size); | 69 CPResponseInfoType type, void* buf, size_t buf_size); |
68 }; | 70 }; |
69 | 71 |
70 // Helper to allocate a string using the given CPB_Alloc function. | 72 // Helper to allocate a string using the given CPB_Alloc function. |
71 inline char* CPB_StringDup(CPB_AllocFunc alloc, const std::string& str) { | 73 inline char* CPB_StringDup(CPB_AllocFunc alloc, const std::string& str) { |
72 char* cstr = static_cast<char*>(alloc(static_cast<uint32>(str.length() + 1))); | 74 char* cstr = static_cast<char*>(alloc(static_cast<uint32>(str.length() + 1))); |
73 memcpy(cstr, str.c_str(), str.length() + 1); // Include null terminator. | 75 memcpy(cstr, str.c_str(), str.length() + 1); // Include null terminator. |
74 return cstr; | 76 return cstr; |
75 } | 77 } |
76 | 78 |
77 CPError CPB_GetCommandLineArgumentsCommon(const char* url, | 79 CPError CPB_GetCommandLineArgumentsCommon(const char* url, |
78 std::string* arguments); | 80 std::string* arguments); |
79 | 81 |
80 void* STDCALL CPB_Alloc(uint32 size); | 82 void* STDCALL CPB_Alloc(uint32 size); |
81 void STDCALL CPB_Free(void* memory); | 83 void STDCALL CPB_Free(void* memory); |
82 | 84 |
83 #endif // CHROME_COMMON_CHROME_PLUGIN_UTIL_H__ | 85 #endif // CHROME_COMMON_CHROME_PLUGIN_UTIL_H__ |
OLD | NEW |