| Index: chrome/browser/devtools/device/android_device_manager.cc | 
| diff --git a/chrome/browser/devtools/device/android_device_manager.cc b/chrome/browser/devtools/device/android_device_manager.cc | 
| index 0459dc89f533cd1e351ed6630fd3f615947929ec..4bec67924d9773418a5391de10ad069e3aab51b6 100644 | 
| --- a/chrome/browser/devtools/device/android_device_manager.cc | 
| +++ b/chrome/browser/devtools/device/android_device_manager.cc | 
| @@ -52,10 +52,11 @@ static void PostHttpUpgradeCallback( | 
| const AndroidDeviceManager::HttpUpgradeCallback& callback, | 
| int result, | 
| const std::string& extensions, | 
| +    const std::string& leading_bytes, | 
| scoped_ptr<net::StreamSocket> socket) { | 
| response_message_loop->PostTask( | 
| -      FROM_HERE, | 
| -      base::Bind(callback, result, extensions, base::Passed(&socket))); | 
| +      FROM_HERE, base::Bind(callback, result, extensions, leading_bytes, | 
| +                            base::Passed(&socket))); | 
| } | 
|  | 
| class HttpRequest { | 
| @@ -79,7 +80,7 @@ class HttpRequest { | 
| int result, | 
| scoped_ptr<net::StreamSocket> socket) { | 
| if (result != net::OK) { | 
| -      callback.Run(result, "", make_scoped_ptr<net::StreamSocket>(nullptr)); | 
| +      callback.Run(result, "", "", make_scoped_ptr<net::StreamSocket>(nullptr)); | 
| return; | 
| } | 
| new HttpRequest(socket.Pass(), request, callback); | 
| @@ -164,13 +165,18 @@ class HttpRequest { | 
| } | 
| } | 
|  | 
| -    if (bytes_total == static_cast<int>(response_.length())) { | 
| -      if (!command_callback_.is_null()) { | 
| -        command_callback_.Run(net::OK, response_.substr(body_pos_)); | 
| -      } else { | 
| -        http_upgrade_callback_.Run(net::OK, | 
| -            ExtractHeader("Sec-WebSocket-Extensions:"), socket_.Pass()); | 
| -      } | 
| +    if (!command_callback_.is_null() && | 
| +        bytes_total == static_cast<int>(response_.length())) { | 
| +      command_callback_.Run(net::OK, response_.substr(body_pos_)); | 
| +      delete this; | 
| +      return; | 
| +    } | 
| + | 
| +    if (!http_upgrade_callback_.is_null() && body_pos_ != std::string::npos && | 
| +        body_pos_ > 0) { | 
| +      http_upgrade_callback_.Run(net::OK, | 
| +                                 ExtractHeader("Sec-WebSocket-Extensions:"), | 
| +                                 response_.substr(body_pos_), socket_.Pass()); | 
| delete this; | 
| return; | 
| } | 
| @@ -207,8 +213,8 @@ class HttpRequest { | 
| if (!command_callback_.is_null()) { | 
| command_callback_.Run(result, std::string()); | 
| } else { | 
| -      http_upgrade_callback_.Run( | 
| -          result, "", make_scoped_ptr<net::StreamSocket>(nullptr)); | 
| +      http_upgrade_callback_.Run(result, "", "", | 
| +                                 make_scoped_ptr<net::StreamSocket>(nullptr)); | 
| } | 
| delete this; | 
| return false; | 
|  |