| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/net/websocket_experiment/websocket_experiment_task.h" | 5 #include "chrome/browser/net/websocket_experiment/websocket_experiment_task.h" |
| 6 | 6 |
| 7 #include "base/hash_tables.h" | 7 #include "base/hash_tables.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "content/browser/browser_thread.h" | 10 #include "content/browser/browser_thread.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 return "draft 75 protocol"; | 28 return "draft 75 protocol"; |
| 29 default: | 29 default: |
| 30 NOTREACHED(); | 30 NOTREACHED(); |
| 31 } | 31 } |
| 32 return ""; | 32 return ""; |
| 33 } | 33 } |
| 34 | 34 |
| 35 URLFetcher* WebSocketExperimentTask::Context::CreateURLFetcher( | 35 URLFetcher* WebSocketExperimentTask::Context::CreateURLFetcher( |
| 36 const Config& config, URLFetcher::Delegate* delegate) { | 36 const Config& config, URLFetcher::Delegate* delegate) { |
| 37 net::URLRequestContextGetter* getter = | 37 net::URLRequestContextGetter* getter = |
| 38 Profile::GetDefaultRequestContext(); | 38 Profile::Deprecated::GetDefaultRequestContext(); |
| 39 // Profile::GetDefaultRequestContext() is initialized lazily, on the UI | 39 // Profile::Deprecated::GetDefaultRequestContext() is initialized lazily, on |
| 40 // thread. So here, where we access it from the IO thread, if the task runs | 40 // the UI thread. So here, where we access it from the IO thread, if the task |
| 41 // before it has gotten lazily initialized yet. | 41 // runs before it has gotten lazily initialized yet. |
| 42 if (!getter) | 42 if (!getter) |
| 43 return NULL; | 43 return NULL; |
| 44 URLFetcher* fetcher = | 44 URLFetcher* fetcher = |
| 45 new URLFetcher(config.http_url, URLFetcher::GET, delegate); | 45 new URLFetcher(config.http_url, URLFetcher::GET, delegate); |
| 46 fetcher->set_request_context(getter); | 46 fetcher->set_request_context(getter); |
| 47 fetcher->set_load_flags( | 47 fetcher->set_load_flags( |
| 48 net::LOAD_BYPASS_CACHE | net::LOAD_DISABLE_CACHE | | 48 net::LOAD_BYPASS_CACHE | net::LOAD_DISABLE_CACHE | |
| 49 net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SEND_AUTH_DATA | | 49 net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SEND_AUTH_DATA | |
| 50 net::LOAD_IGNORE_CERT_AUTHORITY_INVALID); | 50 net::LOAD_IGNORE_CERT_AUTHORITY_INVALID); |
| 51 return fetcher; | 51 return fetcher; |
| 52 } | 52 } |
| 53 | 53 |
| 54 net::WebSocket* WebSocketExperimentTask::Context::CreateWebSocket( | 54 net::WebSocket* WebSocketExperimentTask::Context::CreateWebSocket( |
| 55 const Config& config, net::WebSocketDelegate* delegate) { | 55 const Config& config, net::WebSocketDelegate* delegate) { |
| 56 net::URLRequestContextGetter* getter = | 56 net::URLRequestContextGetter* getter = |
| 57 Profile::GetDefaultRequestContext(); | 57 Profile::Deprecated::GetDefaultRequestContext(); |
| 58 // Profile::GetDefaultRequestContext() is initialized lazily, on the UI | 58 // Profile::Deprecated::GetDefaultRequestContext() is initialized lazily, on |
| 59 // thread. So here, where we access it from the IO thread, if the task runs | 59 // the UI thread. So here, where we access it from the IO thread, if the task |
| 60 // before it has gotten lazily initialized yet. | 60 // runs before it has gotten lazily initialized yet. |
| 61 if (!getter) | 61 if (!getter) |
| 62 return NULL; | 62 return NULL; |
| 63 net::WebSocket::Request* request( | 63 net::WebSocket::Request* request( |
| 64 new net::WebSocket::Request(config.url, | 64 new net::WebSocket::Request(config.url, |
| 65 config.ws_protocol, | 65 config.ws_protocol, |
| 66 config.ws_origin, | 66 config.ws_origin, |
| 67 config.ws_location, | 67 config.ws_location, |
| 68 config.protocol_version, | 68 config.protocol_version, |
| 69 getter->GetURLRequestContext())); | 69 getter->GetURLRequestContext())); |
| 70 return new net::WebSocket(request, delegate); | 70 return new net::WebSocket(request, delegate); |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 if (websocket) | 636 if (websocket) |
| 637 websocket->DetachDelegate(); | 637 websocket->DetachDelegate(); |
| 638 DVLOG(1) << "Finish WebSocket experiment for " << config_.url | 638 DVLOG(1) << "Finish WebSocket experiment for " << config_.url |
| 639 << " " << GetProtocolVersionName(config_.protocol_version) | 639 << " " << GetProtocolVersionName(config_.protocol_version) |
| 640 << " next_state=" << next_state_ | 640 << " next_state=" << next_state_ |
| 641 << " result=" << net::ErrorToString(result); | 641 << " result=" << net::ErrorToString(result); |
| 642 callback_->Run(result); // will release this. | 642 callback_->Run(result); // will release this. |
| 643 } | 643 } |
| 644 | 644 |
| 645 } // namespace chrome_browser_net | 645 } // namespace chrome_browser_net |
| OLD | NEW |