OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 MEDIA_BLINK_URL_INDEX_H_ | 5 #ifndef MEDIA_BLINK_URL_INDEX_H_ |
6 #define MEDIA_BLINK_URL_INDEX_H_ | 6 #define MEDIA_BLINK_URL_INDEX_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
15 #include "media/blink/lru.h" | 15 #include "media/blink/lru.h" |
16 #include "media/blink/media_blink_export.h" | 16 #include "media/blink/media_blink_export.h" |
17 #include "media/blink/multibuffer.h" | 17 #include "media/blink/multibuffer.h" |
18 #include "third_party/WebKit/public/web/WebFrame.h" | 18 #include "third_party/WebKit/public/web/WebFrame.h" |
19 #include "url/gurl.h" | 19 #include "url/gurl.h" |
20 | 20 |
21 namespace media { | 21 namespace media { |
22 | 22 |
23 const int64 kPositionNotSpecified = -1; | 23 const int64_t kPositionNotSpecified = -1; |
24 | 24 |
25 class UrlData; | 25 class UrlData; |
26 | 26 |
27 // A multibuffer for loading media resources which knows | 27 // A multibuffer for loading media resources which knows |
28 // how to create MultiBufferDataProviders to load data | 28 // how to create MultiBufferDataProviders to load data |
29 // into the cache. | 29 // into the cache. |
30 class MEDIA_BLINK_EXPORT ResourceMultiBuffer | 30 class MEDIA_BLINK_EXPORT ResourceMultiBuffer |
31 : NON_EXPORTED_BASE(public MultiBuffer) { | 31 : NON_EXPORTED_BASE(public MultiBuffer) { |
32 public: | 32 public: |
33 ResourceMultiBuffer(UrlData* url_data_, int block_shift); | 33 ResourceMultiBuffer(UrlData* url_data_, int block_shift); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 // Last modified time. | 74 // Last modified time. |
75 base::Time last_modified() const { return last_modified_; } | 75 base::Time last_modified() const { return last_modified_; } |
76 | 76 |
77 // Expiration time. | 77 // Expiration time. |
78 base::Time valid_until() const { return valid_until_; } | 78 base::Time valid_until() const { return valid_until_; } |
79 | 79 |
80 // The key used by UrlIndex to find this UrlData. | 80 // The key used by UrlIndex to find this UrlData. |
81 KeyType key() const; | 81 KeyType key() const; |
82 | 82 |
83 // Length of data associated with url or |kPositionNotSpecified| | 83 // Length of data associated with url or |kPositionNotSpecified| |
84 int64 length() const { return length_; } | 84 int64_t length() const { return length_; } |
85 | 85 |
86 // Returns the number of blocks cached for this resource. | 86 // Returns the number of blocks cached for this resource. |
87 size_t CachedSize(); | 87 size_t CachedSize(); |
88 | 88 |
89 // Returns our url_index, or nullptr if it's been destroyed. | 89 // Returns our url_index, or nullptr if it's been destroyed. |
90 UrlIndex* url_index() const { return url_index_.get(); } | 90 UrlIndex* url_index() const { return url_index_.get(); } |
91 | 91 |
92 // Notifies the url index that this is currently used. | 92 // Notifies the url index that this is currently used. |
93 // The url <-> URLData mapping will be eventually be invalidated if | 93 // The url <-> URLData mapping will be eventually be invalidated if |
94 // this is not called regularly. | 94 // this is not called regularly. |
95 void Use(); | 95 void Use(); |
96 | 96 |
97 // Setters. | 97 // Setters. |
98 void set_length(int64 length); | 98 void set_length(int64_t length); |
99 void set_cacheable(bool cacheable); | 99 void set_cacheable(bool cacheable); |
100 void set_valid_until(base::Time valid_until); | 100 void set_valid_until(base::Time valid_until); |
101 void set_range_supported(); | 101 void set_range_supported(); |
102 void set_last_modified(base::Time last_modified); | 102 void set_last_modified(base::Time last_modified); |
103 | 103 |
104 // A redirect has occured (or we've found a better UrlData for the same | 104 // A redirect has occured (or we've found a better UrlData for the same |
105 // resource). | 105 // resource). |
106 void RedirectTo(const scoped_refptr<UrlData>& to); | 106 void RedirectTo(const scoped_refptr<UrlData>& to); |
107 | 107 |
108 // Fail, tell all clients that a failure has occured. | 108 // Fail, tell all clients that a failure has occured. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 // Url we represent, note that there may be multiple UrlData for | 144 // Url we represent, note that there may be multiple UrlData for |
145 // the same url. | 145 // the same url. |
146 const GURL url_; | 146 const GURL url_; |
147 | 147 |
148 // Cross-origin access mode. | 148 // Cross-origin access mode. |
149 const CORSMode cors_mode_; | 149 const CORSMode cors_mode_; |
150 | 150 |
151 base::WeakPtr<UrlIndex> url_index_; | 151 base::WeakPtr<UrlIndex> url_index_; |
152 | 152 |
153 // Length of resource this url points to. (in bytes) | 153 // Length of resource this url points to. (in bytes) |
154 int64 length_; | 154 int64_t length_; |
155 | 155 |
156 // Does the server support ranges? | 156 // Does the server support ranges? |
157 bool range_supported_; | 157 bool range_supported_; |
158 | 158 |
159 // Set to false if we have reason to beleive the chrome disk cache | 159 // Set to false if we have reason to beleive the chrome disk cache |
160 // will not cache this url. | 160 // will not cache this url. |
161 bool cacheable_; | 161 bool cacheable_; |
162 | 162 |
163 // Last time some media time used this resource. | 163 // Last time some media time used this resource. |
164 // Note that we use base::Time rather than base::TimeTicks because | 164 // Note that we use base::Time rather than base::TimeTicks because |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 // log2 of block size in multibuffer cache. Defaults to kBlockSizeShift. | 233 // log2 of block size in multibuffer cache. Defaults to kBlockSizeShift. |
234 // Currently only changed for testing purposes. | 234 // Currently only changed for testing purposes. |
235 const int block_shift_; | 235 const int block_shift_; |
236 | 236 |
237 protected: | 237 protected: |
238 base::WeakPtrFactory<UrlIndex> weak_factory_; | 238 base::WeakPtrFactory<UrlIndex> weak_factory_; |
239 }; | 239 }; |
240 | 240 |
241 } // namespace media | 241 } // namespace media |
242 #endif // MEDIA_BLINK_URL_INDEX_H_ | 242 #endif // MEDIA_BLINK_URL_INDEX_H_ |
OLD | NEW |