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

Unified Diff: chrome/browser/extensions/api/socket/socket.h

Issue 10095020: Allow socket API to send binary data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch Set 1 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/socket/socket.h
diff --git a/chrome/browser/extensions/api/socket/socket.h b/chrome/browser/extensions/api/socket/socket.h
index 37d2b5797f6401b9ff98cd5ce13fac5a22c7677d..eb9d83e869e961c7e3d117eed69d2ec7f472709b 100644
--- a/chrome/browser/extensions/api/socket/socket.h
+++ b/chrome/browser/extensions/api/socket/socket.h
@@ -31,21 +31,18 @@ class Socket : public APIResource {
virtual int Connect() = 0;
virtual void Disconnect() = 0;
- // Returns a string representing what was able to be read without blocking.
- // If it reads an empty string, or blocks... the behavior is
- // indistinguishable! TODO(miket): this is awful. We should be returning a
- // blob, and we should be giving the caller all needed information about
- // what's happening with the read operation.
- virtual std::string Read();
+ // Returns the number of bytes read into the buffer, or a negative number if
+ // an error occurred.
+ virtual int Read(scoped_refptr<net::IOBuffer> io_buffer, int io_buffer_size);
// Returns the number of bytes successfully written, or a negative error
// code. Note that ERR_IO_PENDING means that the operation blocked, in which
- // case |event_notifier| will eventually be called with the final result
- // (again, either a nonnegative number of bytes written, or a negative
- // error).
- virtual int Write(const std::string& message);
+ // case |event_notifier| (supplied at socket creation) will eventually be
+ // called with the final result (again, either a nonnegative number of bytes
+ // written, or a negative error).
+ virtual int Write(scoped_refptr<net::IOBuffer> io_buffer, int bytes);
- virtual void OnDataRead(int result);
+ virtual void OnDataRead(scoped_refptr<net::IOBuffer> io_buffer, int result);
virtual void OnWriteComplete(int result);
protected:
@@ -56,10 +53,6 @@ class Socket : public APIResource {
const std::string address_;
int port_;
bool is_connected_;
-
- private:
- static const int kMaxRead = 1024;
- scoped_refptr<net::IOBufferWithSize> read_buffer_;
};
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698