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 virtual ~MediaInfoLoader(); | 62 ~MediaInfoLoader() override; |
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 virtual void didSendData( | 83 void didSendData(blink::WebURLLoader* loader, |
84 blink::WebURLLoader* loader, | 84 unsigned long long bytesSent, |
85 unsigned long long bytesSent, | 85 unsigned long long totalBytesToBeSent) override; |
86 unsigned long long totalBytesToBeSent); | 86 void didReceiveResponse(blink::WebURLLoader* loader, |
87 virtual void didReceiveResponse( | 87 const blink::WebURLResponse& response) override; |
88 blink::WebURLLoader* loader, | 88 void didDownloadData(blink::WebURLLoader* loader, |
89 const blink::WebURLResponse& response); | 89 int data_length, |
90 virtual void didDownloadData( | 90 int encodedDataLength) override; |
91 blink::WebURLLoader* loader, | 91 void didReceiveData(blink::WebURLLoader* loader, |
92 int data_length, | 92 const char* data, |
93 int encodedDataLength); | 93 int data_length, |
94 virtual void didReceiveData( | 94 int encoded_data_length) override; |
95 blink::WebURLLoader* loader, | 95 void didReceiveCachedMetadata(blink::WebURLLoader* loader, |
96 const char* data, | 96 const char* data, |
97 int data_length, | 97 int dataLength) override; |
98 int encoded_data_length); | 98 void didFinishLoading(blink::WebURLLoader* loader, |
99 virtual void didReceiveCachedMetadata( | 99 double finishTime, |
100 blink::WebURLLoader* loader, | 100 int64_t total_encoded_data_length) override; |
101 const char* data, int dataLength); | 101 void didFail(blink::WebURLLoader* loader, const blink::WebURLError&) override; |
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&); | |
109 | 102 |
110 void DidBecomeReady(Status status); | 103 void DidBecomeReady(Status status); |
111 | 104 |
112 // Injected WebURLLoader instance for testing purposes. | 105 // Injected WebURLLoader instance for testing purposes. |
113 scoped_ptr<blink::WebURLLoader> test_loader_; | 106 scoped_ptr<blink::WebURLLoader> test_loader_; |
114 | 107 |
115 // Keeps track of an active WebURLLoader and associated state. | 108 // Keeps track of an active WebURLLoader and associated state. |
116 scoped_ptr<media::ActiveLoader> active_loader_; | 109 scoped_ptr<media::ActiveLoader> active_loader_; |
117 | 110 |
118 bool loader_failed_; | 111 bool loader_failed_; |
119 GURL url_; | 112 GURL url_; |
120 GURL first_party_url_; | 113 GURL first_party_url_; |
121 bool allow_stored_credentials_; | 114 bool allow_stored_credentials_; |
122 blink::WebMediaPlayer::CORSMode cors_mode_; | 115 blink::WebMediaPlayer::CORSMode cors_mode_; |
123 bool single_origin_; | 116 bool single_origin_; |
124 | 117 |
125 ReadyCB ready_cb_; | 118 ReadyCB ready_cb_; |
126 base::TimeTicks start_time_; | 119 base::TimeTicks start_time_; |
127 | 120 |
128 DISALLOW_COPY_AND_ASSIGN(MediaInfoLoader); | 121 DISALLOW_COPY_AND_ASSIGN(MediaInfoLoader); |
129 }; | 122 }; |
130 | 123 |
131 } // namespace content | 124 } // namespace content |
132 | 125 |
133 #endif // CONTENT_RENDERER_MEDIA_ANDROID_MEDIA_INFO_LOADER_H_ | 126 #endif // CONTENT_RENDERER_MEDIA_ANDROID_MEDIA_INFO_LOADER_H_ |
OLD | NEW |