OLD | NEW |
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 #include "content/renderer/media/android/media_info_loader.h" | 5 #include "content/renderer/media/android/media_info_loader.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bits.h" | 9 #include "base/bits.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
11 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
12 #include "third_party/WebKit/public/platform/WebURLError.h" | 12 #include "third_party/WebKit/public/platform/WebURLError.h" |
13 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 13 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
14 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 14 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
15 #include "third_party/WebKit/public/web/WebAssociatedURLLoader.h" | 15 #include "third_party/WebKit/public/web/WebAssociatedURLLoader.h" |
16 #include "third_party/WebKit/public/web/WebFrame.h" | 16 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
17 | 17 |
18 using blink::WebAssociatedURLLoader; | 18 using blink::WebAssociatedURLLoader; |
19 using blink::WebAssociatedURLLoaderOptions; | 19 using blink::WebAssociatedURLLoaderOptions; |
20 using blink::WebFrame; | 20 using blink::WebLocalFrame; |
21 using blink::WebURLError; | 21 using blink::WebURLError; |
22 using blink::WebURLRequest; | 22 using blink::WebURLRequest; |
23 using blink::WebURLResponse; | 23 using blink::WebURLResponse; |
24 | 24 |
25 namespace content { | 25 namespace content { |
26 | 26 |
27 static const int kHttpOK = 200; | 27 static const int kHttpOK = 200; |
28 static const int kHttpPartialContentOK = 206; | 28 static const int kHttpPartialContentOK = 206; |
29 | 29 |
30 MediaInfoLoader::MediaInfoLoader( | 30 MediaInfoLoader::MediaInfoLoader( |
31 const GURL& url, | 31 const GURL& url, |
32 blink::WebMediaPlayer::CORSMode cors_mode, | 32 blink::WebMediaPlayer::CORSMode cors_mode, |
33 const ReadyCB& ready_cb) | 33 const ReadyCB& ready_cb) |
34 : loader_failed_(false), | 34 : loader_failed_(false), |
35 url_(url), | 35 url_(url), |
36 allow_stored_credentials_(false), | 36 allow_stored_credentials_(false), |
37 cors_mode_(cors_mode), | 37 cors_mode_(cors_mode), |
38 single_origin_(true), | 38 single_origin_(true), |
39 ready_cb_(ready_cb) {} | 39 ready_cb_(ready_cb) {} |
40 | 40 |
41 MediaInfoLoader::~MediaInfoLoader() {} | 41 MediaInfoLoader::~MediaInfoLoader() {} |
42 | 42 |
43 void MediaInfoLoader::Start(blink::WebFrame* frame) { | 43 void MediaInfoLoader::Start(blink::WebLocalFrame* frame) { |
44 // Make sure we have not started. | 44 // Make sure we have not started. |
45 DCHECK(!ready_cb_.is_null()); | 45 DCHECK(!ready_cb_.is_null()); |
46 CHECK(frame); | 46 CHECK(frame); |
47 | 47 |
48 start_time_ = base::TimeTicks::Now(); | 48 start_time_ = base::TimeTicks::Now(); |
49 first_party_url_ = frame->GetDocument().FirstPartyForCookies(); | 49 first_party_url_ = frame->GetDocument().FirstPartyForCookies(); |
50 | 50 |
51 // Prepare the request. | 51 // Prepare the request. |
52 WebURLRequest request(url_); | 52 WebURLRequest request(url_); |
53 // TODO(mkwst): Split this into video/audio. | 53 // TODO(mkwst): Split this into video/audio. |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 void MediaInfoLoader::DidBecomeReady(Status status) { | 192 void MediaInfoLoader::DidBecomeReady(Status status) { |
193 UMA_HISTOGRAM_TIMES("Media.InfoLoadDelay", | 193 UMA_HISTOGRAM_TIMES("Media.InfoLoadDelay", |
194 base::TimeTicks::Now() - start_time_); | 194 base::TimeTicks::Now() - start_time_); |
195 active_loader_.reset(); | 195 active_loader_.reset(); |
196 if (!ready_cb_.is_null()) | 196 if (!ready_cb_.is_null()) |
197 base::ResetAndReturn(&ready_cb_).Run(status, url_, first_party_url_, | 197 base::ResetAndReturn(&ready_cb_).Run(status, url_, first_party_url_, |
198 allow_stored_credentials_); | 198 allow_stored_credentials_); |
199 } | 199 } |
200 | 200 |
201 } // namespace content | 201 } // namespace content |
OLD | NEW |