Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(615)

Side by Side Diff: chrome/browser/extensions/api/api_resource_event_notifier.h

Issue 10095020: Allow socket API to send binary data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Jeremy's judgments. Antonits. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/api/api_resource_event_notifier.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 {
20 class ListValue;
21 }
22
19 namespace extensions { 23 namespace extensions {
20 24
21 enum APIResourceEventType { 25 enum APIResourceEventType {
22 API_RESOURCE_EVENT_CONNECT_COMPLETE, 26 API_RESOURCE_EVENT_CONNECT_COMPLETE,
23 API_RESOURCE_EVENT_DATA_READ, 27 API_RESOURCE_EVENT_DATA_READ,
24 API_RESOURCE_EVENT_WRITE_COMPLETE 28 API_RESOURCE_EVENT_WRITE_COMPLETE
25 }; 29 };
26 30
27 extern const char kSrcIdKey[]; 31 extern const char kSrcIdKey[];
28 32
(...skipping 11 matching lines...) Expand all
40 class APIResourceEventNotifier 44 class APIResourceEventNotifier
41 : public base::RefCountedThreadSafe<APIResourceEventNotifier> { 45 : public base::RefCountedThreadSafe<APIResourceEventNotifier> {
42 public: 46 public:
43 APIResourceEventNotifier(ExtensionEventRouter* router, 47 APIResourceEventNotifier(ExtensionEventRouter* router,
44 Profile* profile, 48 Profile* profile,
45 const std::string& src_extension_id, int src_id, 49 const std::string& src_extension_id, int src_id,
46 const GURL& src_url); 50 const GURL& src_url);
47 virtual ~APIResourceEventNotifier(); 51 virtual ~APIResourceEventNotifier();
48 52
49 virtual void OnConnectComplete(int result_code); 53 virtual void OnConnectComplete(int result_code);
50 virtual void OnDataRead(int result_code, const std::string& data); 54
55 // Takes ownership of data.
56 virtual void OnDataRead(int result_code, base::ListValue* data);
57
51 virtual void OnWriteComplete(int result_code); 58 virtual void OnWriteComplete(int result_code);
52 59
53 static std::string APIResourceEventTypeToString( 60 static std::string APIResourceEventTypeToString(
54 APIResourceEventType event_type); 61 APIResourceEventType event_type);
55 62
56 private: 63 private:
57 void DispatchEvent(DictionaryValue* event); 64 void DispatchEvent(DictionaryValue* event);
58 void DispatchEventOnUIThread(DictionaryValue* event); 65 void DispatchEventOnUIThread(DictionaryValue* event);
59 DictionaryValue* CreateAPIResourceEvent(APIResourceEventType event_type); 66 DictionaryValue* CreateAPIResourceEvent(APIResourceEventType event_type);
60 67
61 void SendEventWithResultCode(APIResourceEventType event_type, 68 void SendEventWithResultCode(APIResourceEventType event_type,
62 int result_code); 69 int result_code);
63 70
64 ExtensionEventRouter* router_; 71 ExtensionEventRouter* router_;
65 Profile* profile_; 72 Profile* profile_;
66 std::string src_extension_id_; 73 std::string src_extension_id_;
67 int src_id_; 74 int src_id_;
68 GURL src_url_; 75 GURL src_url_;
69 76
70 DISALLOW_COPY_AND_ASSIGN(APIResourceEventNotifier); 77 DISALLOW_COPY_AND_ASSIGN(APIResourceEventNotifier);
71 }; 78 };
72 79
73 } // namespace extensions 80 } // namespace extensions
74 81
75 #endif // CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_EVENT_NOTIFIER_H_ 82 #endif // CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_EVENT_NOTIFIER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/api_resource_event_notifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698