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

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

Issue 10777003: Refactor APIResourceController to ProfileKeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge/antony/fix build. Created 8 years, 5 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
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_SOCKET_SOCKET_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 14 matching lines...) Expand all
25 25
26 typedef base::Callback<void(int)> CompletionCallback; 26 typedef base::Callback<void(int)> CompletionCallback;
27 typedef base::Callback<void(int, scoped_refptr<net::IOBuffer> io_buffer)> 27 typedef base::Callback<void(int, scoped_refptr<net::IOBuffer> io_buffer)>
28 ReadCompletionCallback; 28 ReadCompletionCallback;
29 typedef base::Callback< 29 typedef base::Callback<
30 void(int, scoped_refptr<net::IOBuffer> io_buffer, const std::string&, int)> 30 void(int, scoped_refptr<net::IOBuffer> io_buffer, const std::string&, int)>
31 RecvFromCompletionCallback; 31 RecvFromCompletionCallback;
32 32
33 // A Socket wraps a low-level socket and includes housekeeping information that 33 // A Socket wraps a low-level socket and includes housekeeping information that
34 // we need to manage it in the context of an extension. 34 // we need to manage it in the context of an extension.
35 class Socket : public APIResource { 35 class Socket : public ApiResource {
36 public: 36 public:
37 virtual ~Socket(); 37 virtual ~Socket();
38 virtual void Connect(const std::string& address, 38 virtual void Connect(const std::string& address,
39 int port, 39 int port,
40 const CompletionCallback& callback) = 0; 40 const CompletionCallback& callback) = 0;
41 virtual void Disconnect() = 0; 41 virtual void Disconnect() = 0;
42 virtual int Bind(const std::string& address, int port) = 0; 42 virtual int Bind(const std::string& address, int port) = 0;
43 43
44 // The |callback| will be called with the number of bytes read into the 44 // The |callback| will be called with the number of bytes read into the
45 // buffer, or a negative number if an error occurred. 45 // buffer, or a negative number if an error occurred.
(...skipping 21 matching lines...) Expand all
67 int port, 67 int port,
68 net::AddressList* address_list); 68 net::AddressList* address_list);
69 static bool StringAndPortToIPEndPoint(const std::string& ip_address_str, 69 static bool StringAndPortToIPEndPoint(const std::string& ip_address_str,
70 int port, 70 int port,
71 net::IPEndPoint* ip_end_point); 71 net::IPEndPoint* ip_end_point);
72 static void IPEndPointToStringAndPort(const net::IPEndPoint& address, 72 static void IPEndPointToStringAndPort(const net::IPEndPoint& address,
73 std::string* ip_address_str, 73 std::string* ip_address_str,
74 int* port); 74 int* port);
75 75
76 protected: 76 protected:
77 explicit Socket(APIResourceEventNotifier* event_notifier); 77 explicit Socket(ApiResourceEventNotifier* event_notifier);
78 78
79 void WriteData(); 79 void WriteData();
80 virtual int WriteImpl(net::IOBuffer* io_buffer, 80 virtual int WriteImpl(net::IOBuffer* io_buffer,
81 int io_buffer_size, 81 int io_buffer_size,
82 const net::CompletionCallback& callback) = 0; 82 const net::CompletionCallback& callback) = 0;
83 virtual void OnWriteComplete(int result); 83 virtual void OnWriteComplete(int result);
84 84
85 const std::string address_; 85 const std::string address_;
86 int port_; 86 int port_;
87 bool is_connected_; 87 bool is_connected_;
(...skipping 13 matching lines...) Expand all
101 CompletionCallback callback; 101 CompletionCallback callback;
102 int bytes_written; 102 int bytes_written;
103 }; 103 };
104 std::queue<WriteRequest> write_queue_; 104 std::queue<WriteRequest> write_queue_;
105 scoped_refptr<net::IOBuffer> io_buffer_write_; 105 scoped_refptr<net::IOBuffer> io_buffer_write_;
106 }; 106 };
107 107
108 } // namespace extensions 108 } // namespace extensions
109 109
110 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_H_ 110 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/serial/serial_connection.cc ('k') | chrome/browser/extensions/api/socket/socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698