| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 EXTENSIONS_BROWSER_API_SOCKETS_UDP_UDP_SOCKET_EVENT_DISPATCHER_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_SOCKETS_UDP_UDP_SOCKET_EVENT_DISPATCHER_H_ |
| 6 #define EXTENSIONS_BROWSER_API_SOCKETS_UDP_UDP_SOCKET_EVENT_DISPATCHER_H_ | 6 #define EXTENSIONS_BROWSER_API_SOCKETS_UDP_UDP_SOCKET_EVENT_DISPATCHER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 8 #include <string> | 10 #include <string> |
| 9 | 11 |
| 10 #include "extensions/browser/api/api_resource_manager.h" | 12 #include "extensions/browser/api/api_resource_manager.h" |
| 11 #include "extensions/browser/api/sockets_udp/sockets_udp_api.h" | 13 #include "extensions/browser/api/sockets_udp/sockets_udp_api.h" |
| 12 | 14 |
| 13 namespace content { | 15 namespace content { |
| 14 class BrowserContext; | 16 class BrowserContext; |
| 15 } | 17 } |
| 16 | 18 |
| 17 namespace extensions { | 19 namespace extensions { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 }; | 68 }; |
| 67 | 69 |
| 68 // Start a receive and register a callback. | 70 // Start a receive and register a callback. |
| 69 static void StartReceive(const ReceiveParams& params); | 71 static void StartReceive(const ReceiveParams& params); |
| 70 | 72 |
| 71 // Called when socket receive data. | 73 // Called when socket receive data. |
| 72 static void ReceiveCallback(const ReceiveParams& params, | 74 static void ReceiveCallback(const ReceiveParams& params, |
| 73 int bytes_read, | 75 int bytes_read, |
| 74 scoped_refptr<net::IOBuffer> io_buffer, | 76 scoped_refptr<net::IOBuffer> io_buffer, |
| 75 const std::string& address, | 77 const std::string& address, |
| 76 uint16 port); | 78 uint16_t port); |
| 77 | 79 |
| 78 // Post an extension event from IO to UI thread | 80 // Post an extension event from IO to UI thread |
| 79 static void PostEvent(const ReceiveParams& params, scoped_ptr<Event> event); | 81 static void PostEvent(const ReceiveParams& params, scoped_ptr<Event> event); |
| 80 | 82 |
| 81 // Dispatch an extension event on to EventRouter instance on UI thread. | 83 // Dispatch an extension event on to EventRouter instance on UI thread. |
| 82 static void DispatchEvent(void* browser_context_id, | 84 static void DispatchEvent(void* browser_context_id, |
| 83 const std::string& extension_id, | 85 const std::string& extension_id, |
| 84 scoped_ptr<Event> event); | 86 scoped_ptr<Event> event); |
| 85 | 87 |
| 86 // Usually IO thread (except for unit testing). | 88 // Usually IO thread (except for unit testing). |
| 87 content::BrowserThread::ID thread_id_; | 89 content::BrowserThread::ID thread_id_; |
| 88 content::BrowserContext* const browser_context_; | 90 content::BrowserContext* const browser_context_; |
| 89 scoped_refptr<SocketData> sockets_; | 91 scoped_refptr<SocketData> sockets_; |
| 90 }; | 92 }; |
| 91 | 93 |
| 92 } // namespace api | 94 } // namespace api |
| 93 } // namespace extensions | 95 } // namespace extensions |
| 94 | 96 |
| 95 #endif // EXTENSIONS_BROWSER_API_SOCKETS_UDP_UDP_SOCKET_EVENT_DISPATCHER_H_ | 97 #endif // EXTENSIONS_BROWSER_API_SOCKETS_UDP_UDP_SOCKET_EVENT_DISPATCHER_H_ |
| OLD | NEW |