Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: media/blink/url_index.h

Issue 1399603003: Tie multibuffers to URLs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@media_cache
Patch Set: added MEDIA_BLINK_EXPORT Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/threading/thread_checker.h" 12 #include "base/threading/thread_checker.h"
13 #include "media/base/media_export.h"
14 #include "media/blink/lru.h" 13 #include "media/blink/lru.h"
14 #include "media/blink/media_blink_export.h"
15 #include "url/gurl.h" 15 #include "url/gurl.h"
16 16
17 namespace media { 17 namespace media {
18 18
19 #ifndef MEDIA_BLINK_BUFFERED_RESOURCE_LOADER_H_
20 const int64 kPositionNotSpecified = -1; 19 const int64 kPositionNotSpecified = -1;
21 #endif
22 20
23 class UrlIndex; 21 class UrlIndex;
24 22
25 class MEDIA_EXPORT UrlData : public base::RefCounted<UrlData> { 23 class MEDIA_BLINK_EXPORT UrlData : public base::RefCounted<UrlData> {
26 public: 24 public:
27 // Keep in sync with WebMediaPlayer::CORSMode. 25 // Keep in sync with WebMediaPlayer::CORSMode.
28 enum CORSMode { kUnspecified, kAnonymous, kUseCredentials }; 26 enum CORSMode { kUnspecified, kAnonymous, kUseCredentials };
29 typedef std::pair<GURL, CORSMode> KeyType; 27 typedef std::pair<GURL, CORSMode> KeyType;
30 28
31 const GURL url() const { return url_; } 29 const GURL url() const { return url_; }
32 const GURL redirects_to() const { return redirects_to_; } 30 const GURL redirects_to() const { return redirects_to_; }
33 CORSMode cors_mode() const { return cors_mode_; } 31 CORSMode cors_mode() const { return cors_mode_; }
34 bool range_supported() const { return range_supported_; } 32 bool range_supported() const { return range_supported_; }
35 bool cacheable() const { return cacheable_; } 33 bool cacheable() const { return cacheable_; }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 UrlIndex* url_index_; 91 UrlIndex* url_index_;
94 DISALLOW_COPY_AND_ASSIGN(UrlData); 92 DISALLOW_COPY_AND_ASSIGN(UrlData);
95 }; 93 };
96 94
97 // The UrlIndex lets you look up UrlData instances by url. 95 // The UrlIndex lets you look up UrlData instances by url.
98 // It keeps a weak reference to UrlData that it has returned. 96 // It keeps a weak reference to UrlData that it has returned.
99 // Since the multibuffer cache key contains an UrlData reference 97 // Since the multibuffer cache key contains an UrlData reference
100 // we can be sure that UrlData instances with zero references 98 // we can be sure that UrlData instances with zero references
101 // do not have any cached data associated with them, and they 99 // do not have any cached data associated with them, and they
102 // can safely be removed from the UrlIndex. 100 // can safely be removed from the UrlIndex.
103 class MEDIA_EXPORT UrlIndex { 101 class MEDIA_BLINK_EXPORT UrlIndex {
104 public: 102 public:
105 UrlIndex(); 103 UrlIndex();
106 ~UrlIndex(); 104 ~UrlIndex();
107 // Creates a new UrlData if not found. 105 // Creates a new UrlData if not found.
108 // |last_modified| may be null if not known. 106 // |last_modified| may be null if not known.
109 // Normally you'll want to call Use() on the returned object right away. 107 // Normally you'll want to call Use() on the returned object right away.
110 scoped_refptr<UrlData> GetByUrl(const GURL& gurl, 108 scoped_refptr<UrlData> GetByUrl(const GURL& gurl,
111 UrlData::CORSMode cors_mode); 109 UrlData::CORSMode cors_mode);
112 110
113 111
114 private: 112 private:
115 friend class UrlData; 113 friend class UrlData;
116 void RemoveUrlData(const UrlData* url_data); 114 void RemoveUrlData(const UrlData* url_data);
117 // TODO(hubbe): Add support for etag validation. 115 // TODO(hubbe): Add support for etag validation.
118 scoped_refptr<UrlData> SetLastModified(scoped_refptr<UrlData> urldata, 116 scoped_refptr<UrlData> SetLastModified(scoped_refptr<UrlData> urldata,
119 base::Time last_modified); 117 base::Time last_modified);
120 118
121 std::map<UrlData::KeyType, UrlData*> by_url_; 119 std::map<UrlData::KeyType, UrlData*> by_url_;
122 std::map<UrlData::KeyType, UrlData*> with_last_modified_; 120 std::map<UrlData::KeyType, UrlData*> with_last_modified_;
123 std::list<scoped_refptr<UrlData> > to_prune_; 121 std::list<scoped_refptr<UrlData> > to_prune_;
124 bool prune_cb_active_; 122 bool prune_cb_active_;
125 }; 123 };
126 124
127 } // namespace media 125 } // namespace media
128 #endif // MEDIA_BLINK_URL_INDEX_H_ 126 #endif // MEDIA_BLINK_URL_INDEX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698