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

Side by Side Diff: chrome/browser/extensions/api/cast_channel/cast_socket.h

Issue 408633002: Fix error handling for message parse errors that occur during connection setup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed superfluous size check Created 6 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_CAST_CHANNEL_CAST_SOCKET_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_CAST_CHANNEL_CAST_SOCKET_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_CAST_CHANNEL_CAST_SOCKET_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_CAST_CHANNEL_CAST_SOCKET_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <string> 9 #include <string>
10 10
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // READY_STATE_CLOSED. 116 // READY_STATE_CLOSED.
117 // It is fine to delete the CastSocket object in |callback|. 117 // It is fine to delete the CastSocket object in |callback|.
118 virtual void Close(const net::CompletionCallback& callback); 118 virtual void Close(const net::CompletionCallback& callback);
119 119
120 protected: 120 protected:
121 // Message header struct. If fields are added, be sure to update 121 // Message header struct. If fields are added, be sure to update
122 // header_size(). Protected to allow use of *_size() methods in unit tests. 122 // header_size(). Protected to allow use of *_size() methods in unit tests.
123 struct MessageHeader { 123 struct MessageHeader {
124 MessageHeader(); 124 MessageHeader();
125 // Sets the message size. 125 // Sets the message size.
126 void SetMessageSize(size_t message_size); 126 bool SetMessageSize(size_t message_size);
Wez 2014/07/24 00:55:55 This no longer needs the Boolean return. :)
127 // Prepends this header to |str|. 127 // Prepends this header to |str|.
128 void PrependToString(std::string* str); 128 void PrependToString(std::string* str);
129 // Reads |header| from the beginning of |buffer|. 129 // Reads |header| from the beginning of |buffer|.
130 static void ReadFromIOBuffer(net::GrowableIOBuffer* buffer, 130 static void ReadFromIOBuffer(net::GrowableIOBuffer* buffer,
131 MessageHeader* header); 131 MessageHeader* header);
132 // Size (in bytes) of the message header. 132 // Size (in bytes) of the message header.
133 static uint32 header_size() { return sizeof(uint32); } 133 static uint32 header_size() { return sizeof(uint32); }
134 134
135 // Maximum size (in bytes) of a message payload on the wire (does not 135 // Maximum size (in bytes) of a message payload on the wire (does not
136 // include header). 136 // include header).
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 FRIEND_TEST_ALL_PREFIXES(CastSocketTest, TestReadMany); 347 FRIEND_TEST_ALL_PREFIXES(CastSocketTest, TestReadMany);
348 FRIEND_TEST_ALL_PREFIXES(CastSocketTest, TestWriteErrorLargeMessage); 348 FRIEND_TEST_ALL_PREFIXES(CastSocketTest, TestWriteErrorLargeMessage);
349 DISALLOW_COPY_AND_ASSIGN(CastSocket); 349 DISALLOW_COPY_AND_ASSIGN(CastSocket);
350 }; 350 };
351 351
352 } // namespace cast_channel 352 } // namespace cast_channel
353 } // namespace api 353 } // namespace api
354 } // namespace extensions 354 } // namespace extensions
355 355
356 #endif // CHROME_BROWSER_EXTENSIONS_API_CAST_CHANNEL_CAST_SOCKET_H_ 356 #endif // CHROME_BROWSER_EXTENSIONS_API_CAST_CHANNEL_CAST_SOCKET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698