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 #ifndef CONTENT_RENDERER_MEDIA_ANDROID_MEDIA_INFO_LOADER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_ANDROID_MEDIA_INFO_LOADER_H_ |
6 #define CONTENT_RENDERER_MEDIA_ANDROID_MEDIA_INFO_LOADER_H_ | 6 #define CONTENT_RENDERER_MEDIA_ANDROID_MEDIA_INFO_LOADER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 typedef base::Callback<void(Status, const GURL&, const GURL&, bool)> ReadyCB; | 52 typedef base::Callback<void(Status, const GURL&, const GURL&, bool)> ReadyCB; |
53 | 53 |
54 // Start loading information about the given media URL. | 54 // Start loading information about the given media URL. |
55 // |url| - URL for the media resource to be loaded. | 55 // |url| - URL for the media resource to be loaded. |
56 // |cors_mode| - HTML media element's crossorigin attribute. | 56 // |cors_mode| - HTML media element's crossorigin attribute. |
57 // |ready_cb| - Called when media info has finished or failed loading. | 57 // |ready_cb| - Called when media info has finished or failed loading. |
58 MediaInfoLoader( | 58 MediaInfoLoader( |
59 const GURL& url, | 59 const GURL& url, |
60 blink::WebMediaPlayer::CORSMode cors_mode, | 60 blink::WebMediaPlayer::CORSMode cors_mode, |
61 const ReadyCB& ready_cb); | 61 const ReadyCB& ready_cb); |
62 ~MediaInfoLoader() override; | 62 virtual ~MediaInfoLoader(); |
63 | 63 |
64 // Start loading media info. | 64 // Start loading media info. |
65 void Start(blink::WebFrame* frame); | 65 void Start(blink::WebFrame* frame); |
66 | 66 |
67 // Returns true if the media resource has a single origin, false otherwise. | 67 // Returns true if the media resource has a single origin, false otherwise. |
68 // Only valid to call after the loader becomes ready. | 68 // Only valid to call after the loader becomes ready. |
69 bool HasSingleOrigin() const; | 69 bool HasSingleOrigin() const; |
70 | 70 |
71 // Returns true if the media resource passed a CORS access control check. | 71 // Returns true if the media resource passed a CORS access control check. |
72 // Only valid to call after the loader becomes ready. | 72 // Only valid to call after the loader becomes ready. |
73 bool DidPassCORSAccessCheck() const; | 73 bool DidPassCORSAccessCheck() const; |
74 | 74 |
75 private: | 75 private: |
76 friend class MediaInfoLoaderTest; | 76 friend class MediaInfoLoaderTest; |
77 | 77 |
78 // blink::WebURLLoaderClient implementation. | 78 // blink::WebURLLoaderClient implementation. |
79 virtual void willSendRequest( | 79 virtual void willSendRequest( |
80 blink::WebURLLoader* loader, | 80 blink::WebURLLoader* loader, |
81 blink::WebURLRequest& newRequest, | 81 blink::WebURLRequest& newRequest, |
82 const blink::WebURLResponse& redirectResponse); | 82 const blink::WebURLResponse& redirectResponse); |
83 void didSendData(blink::WebURLLoader* loader, | 83 virtual void didSendData( |
84 unsigned long long bytesSent, | 84 blink::WebURLLoader* loader, |
85 unsigned long long totalBytesToBeSent) override; | 85 unsigned long long bytesSent, |
86 void didReceiveResponse(blink::WebURLLoader* loader, | 86 unsigned long long totalBytesToBeSent); |
87 const blink::WebURLResponse& response) override; | 87 virtual void didReceiveResponse( |
88 void didDownloadData(blink::WebURLLoader* loader, | 88 blink::WebURLLoader* loader, |
89 int data_length, | 89 const blink::WebURLResponse& response); |
90 int encodedDataLength) override; | 90 virtual void didDownloadData( |
91 void didReceiveData(blink::WebURLLoader* loader, | 91 blink::WebURLLoader* loader, |
92 const char* data, | 92 int data_length, |
93 int data_length, | 93 int encodedDataLength); |
94 int encoded_data_length) override; | 94 virtual void didReceiveData( |
95 void didReceiveCachedMetadata(blink::WebURLLoader* loader, | 95 blink::WebURLLoader* loader, |
96 const char* data, | 96 const char* data, |
97 int dataLength) override; | 97 int data_length, |
98 void didFinishLoading(blink::WebURLLoader* loader, | 98 int encoded_data_length); |
99 double finishTime, | 99 virtual void didReceiveCachedMetadata( |
100 int64_t total_encoded_data_length) override; | 100 blink::WebURLLoader* loader, |
101 void didFail(blink::WebURLLoader* loader, const blink::WebURLError&) override; | 101 const char* data, int dataLength); |
| 102 virtual void didFinishLoading( |
| 103 blink::WebURLLoader* loader, |
| 104 double finishTime, |
| 105 int64_t total_encoded_data_length); |
| 106 virtual void didFail( |
| 107 blink::WebURLLoader* loader, |
| 108 const blink::WebURLError&); |
102 | 109 |
103 void DidBecomeReady(Status status); | 110 void DidBecomeReady(Status status); |
104 | 111 |
105 // Injected WebURLLoader instance for testing purposes. | 112 // Injected WebURLLoader instance for testing purposes. |
106 scoped_ptr<blink::WebURLLoader> test_loader_; | 113 scoped_ptr<blink::WebURLLoader> test_loader_; |
107 | 114 |
108 // Keeps track of an active WebURLLoader and associated state. | 115 // Keeps track of an active WebURLLoader and associated state. |
109 scoped_ptr<media::ActiveLoader> active_loader_; | 116 scoped_ptr<media::ActiveLoader> active_loader_; |
110 | 117 |
111 bool loader_failed_; | 118 bool loader_failed_; |
112 GURL url_; | 119 GURL url_; |
113 GURL first_party_url_; | 120 GURL first_party_url_; |
114 bool allow_stored_credentials_; | 121 bool allow_stored_credentials_; |
115 blink::WebMediaPlayer::CORSMode cors_mode_; | 122 blink::WebMediaPlayer::CORSMode cors_mode_; |
116 bool single_origin_; | 123 bool single_origin_; |
117 | 124 |
118 ReadyCB ready_cb_; | 125 ReadyCB ready_cb_; |
119 base::TimeTicks start_time_; | 126 base::TimeTicks start_time_; |
120 | 127 |
121 DISALLOW_COPY_AND_ASSIGN(MediaInfoLoader); | 128 DISALLOW_COPY_AND_ASSIGN(MediaInfoLoader); |
122 }; | 129 }; |
123 | 130 |
124 } // namespace content | 131 } // namespace content |
125 | 132 |
126 #endif // CONTENT_RENDERER_MEDIA_ANDROID_MEDIA_INFO_LOADER_H_ | 133 #endif // CONTENT_RENDERER_MEDIA_ANDROID_MEDIA_INFO_LOADER_H_ |
OLD | NEW |