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 #ifndef CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_EVENT_NOTIFIER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_EVENT_NOTIFIER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_EVENT_NOTIFIER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_EVENT_NOTIFIER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
15 | 15 |
16 class ExtensionEventRouter; | 16 class ExtensionEventRouter; |
17 class Profile; | 17 class Profile; |
18 | 18 |
19 namespace base { | 19 namespace base { |
20 class ListValue; | 20 class ListValue; |
21 } | 21 } |
22 | 22 |
23 namespace extensions { | 23 namespace extensions { |
24 | 24 |
25 enum APIResourceEventType { | 25 enum APIResourceEventType { |
26 API_RESOURCE_EVENT_CONNECT_COMPLETE, | 26 API_RESOURCE_EVENT_CONNECT_COMPLETE, |
27 API_RESOURCE_EVENT_DATA_READ, | 27 API_RESOURCE_EVENT_DATA_READ, |
28 API_RESOURCE_EVENT_WRITE_COMPLETE | 28 API_RESOURCE_EVENT_WRITE_COMPLETE, |
| 29 API_RESOURCE_EVENT_TRANSFER_COMPLETE, |
29 }; | 30 }; |
30 | 31 |
31 extern const char kSrcIdKey[]; | 32 extern const char kSrcIdKey[]; |
32 | 33 |
33 // TODO(miket): It's possible that we'll further refactor these new classes in | 34 // TODO(miket): It's possible that we'll further refactor these new classes in |
34 // light of some changes that mihaip has suggested. The names might change, | 35 // light of some changes that mihaip has suggested. The names might change, |
35 // too: | 36 // too: |
36 // | 37 // |
37 // IOResource | 38 // IOResource |
38 // IOResourceExtensionFunction | 39 // IOResourceExtensionFunction |
(...skipping 14 matching lines...) Expand all Loading... |
53 virtual void OnConnectComplete(int result_code); | 54 virtual void OnConnectComplete(int result_code); |
54 | 55 |
55 // Takes ownership of data. | 56 // Takes ownership of data. |
56 virtual void OnDataRead(int result_code, | 57 virtual void OnDataRead(int result_code, |
57 base::ListValue* data, | 58 base::ListValue* data, |
58 const std::string& address, | 59 const std::string& address, |
59 int port); | 60 int port); |
60 | 61 |
61 virtual void OnWriteComplete(int result_code); | 62 virtual void OnWriteComplete(int result_code); |
62 | 63 |
| 64 virtual void OnTransferComplete(int result_code, base::ListValue* data); |
| 65 |
63 static std::string APIResourceEventTypeToString( | 66 static std::string APIResourceEventTypeToString( |
64 APIResourceEventType event_type); | 67 APIResourceEventType event_type); |
65 | 68 |
66 private: | 69 private: |
67 void DispatchEvent(DictionaryValue* event); | 70 void DispatchEvent(const std::string &extension, DictionaryValue* event); |
68 void DispatchEventOnUIThread(DictionaryValue* event); | 71 void DispatchEventOnUIThread(const std::string &extension, |
| 72 DictionaryValue* event); |
69 DictionaryValue* CreateAPIResourceEvent(APIResourceEventType event_type); | 73 DictionaryValue* CreateAPIResourceEvent(APIResourceEventType event_type); |
70 | 74 |
71 void SendEventWithResultCode(APIResourceEventType event_type, | 75 void SendEventWithResultCode(const std::string &extension, |
| 76 APIResourceEventType event_type, |
72 int result_code); | 77 int result_code); |
73 | 78 |
74 ExtensionEventRouter* router_; | 79 ExtensionEventRouter* router_; |
75 Profile* profile_; | 80 Profile* profile_; |
76 std::string src_extension_id_; | 81 std::string src_extension_id_; |
77 int src_id_; | 82 int src_id_; |
78 GURL src_url_; | 83 GURL src_url_; |
79 | 84 |
80 DISALLOW_COPY_AND_ASSIGN(APIResourceEventNotifier); | 85 DISALLOW_COPY_AND_ASSIGN(APIResourceEventNotifier); |
81 }; | 86 }; |
82 | 87 |
83 } // namespace extensions | 88 } // namespace extensions |
84 | 89 |
85 #endif // CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_EVENT_NOTIFIER_H_ | 90 #endif // CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_EVENT_NOTIFIER_H_ |
OLD | NEW |