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 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/usb/usb_device.h" | 13 #include "chrome/browser/usb/usb_device.h" |
14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
15 | 15 |
16 class Profile; | 16 class Profile; |
17 | 17 |
18 namespace base { | 18 namespace base { |
19 class ListValue; | 19 class ListValue; |
20 } | 20 } |
21 | 21 |
22 namespace extensions { | 22 namespace extensions { |
23 class EventRouter; | 23 class EventRouter; |
24 | 24 |
25 enum ApiResourceEventType { | 25 enum ApiResourceEventType { |
26 API_RESOURCE_EVENT_CONNECT_COMPLETE, | |
27 API_RESOURCE_EVENT_DATA_READ, | |
28 API_RESOURCE_EVENT_WRITE_COMPLETE, | |
29 API_RESOURCE_EVENT_TRANSFER_COMPLETE, | 26 API_RESOURCE_EVENT_TRANSFER_COMPLETE, |
30 }; | 27 }; |
31 | 28 |
32 extern const char kSrcIdKey[]; | 29 extern const char kSrcIdKey[]; |
33 | 30 |
34 // ApiResourceEventNotifier knows how to send an event to a specific app's | 31 // ApiResourceEventNotifier knows how to send an event to a specific app's |
35 // onEvent handler. | 32 // onEvent handler. |
36 class ApiResourceEventNotifier | 33 class ApiResourceEventNotifier |
37 : public base::RefCountedThreadSafe<ApiResourceEventNotifier> { | 34 : public base::RefCountedThreadSafe<ApiResourceEventNotifier> { |
38 public: | 35 public: |
39 ApiResourceEventNotifier(EventRouter* router, | 36 ApiResourceEventNotifier(EventRouter* router, |
40 Profile* profile, | 37 Profile* profile, |
41 const std::string& src_extension_id, int src_id, | 38 const std::string& src_extension_id, int src_id, |
42 const GURL& src_url); | 39 const GURL& src_url); |
43 | 40 |
41 #if 0 | |
miket_OOO
2012/07/27 19:21:24
Just remove the code. No #if 0 in non-test code.
Peng
2012/07/27 19:31:42
Done.
| |
44 virtual void OnConnectComplete(int result_code); | 42 virtual void OnConnectComplete(int result_code); |
45 | 43 |
46 // Takes ownership of data. | 44 // Takes ownership of data. |
47 virtual void OnDataRead(int result_code, | 45 virtual void OnDataRead(int result_code, |
48 base::ListValue* data, | 46 base::ListValue* data, |
49 const std::string& address, | 47 const std::string& address, |
50 int port); | 48 int port); |
51 | 49 |
52 virtual void OnWriteComplete(int result_code); | 50 virtual void OnWriteComplete(int result_code); |
53 | 51 #endif |
54 virtual void OnTransferComplete(UsbTransferStatus status, | 52 virtual void OnTransferComplete(UsbTransferStatus status, |
55 const std::string& error, | 53 const std::string& error, |
56 base::BinaryValue* data); | 54 base::BinaryValue* data); |
57 | 55 |
58 static std::string ApiResourceEventTypeToString( | 56 static std::string ApiResourceEventTypeToString( |
59 ApiResourceEventType event_type); | 57 ApiResourceEventType event_type); |
60 | 58 |
61 private: | 59 private: |
62 friend class base::RefCountedThreadSafe<ApiResourceEventNotifier>; | 60 friend class base::RefCountedThreadSafe<ApiResourceEventNotifier>; |
63 friend class MockApiResourceEventNotifier; | 61 friend class MockApiResourceEventNotifier; |
(...skipping 14 matching lines...) Expand all Loading... | |
78 std::string src_extension_id_; | 76 std::string src_extension_id_; |
79 int src_id_; | 77 int src_id_; |
80 GURL src_url_; | 78 GURL src_url_; |
81 | 79 |
82 DISALLOW_COPY_AND_ASSIGN(ApiResourceEventNotifier); | 80 DISALLOW_COPY_AND_ASSIGN(ApiResourceEventNotifier); |
83 }; | 81 }; |
84 | 82 |
85 } // namespace extensions | 83 } // namespace extensions |
86 | 84 |
87 #endif // CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_EVENT_NOTIFIER_H_ | 85 #endif // CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_EVENT_NOTIFIER_H_ |
OLD | NEW |