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

Side by Side Diff: content/browser/streams/stream_registry.h

Issue 22908008: Limit the total memory usage for Stream instances (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: kinuko's comment and rebase Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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_BROWSER_STREAMS_STREAM_REGISTRY_H_ 5 #ifndef CONTENT_BROWSER_STREAMS_STREAM_REGISTRY_H_
6 #define CONTENT_BROWSER_STREAMS_STREAM_REGISTRY_H_ 6 #define CONTENT_BROWSER_STREAMS_STREAM_REGISTRY_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 14 matching lines...) Expand all
25 25
26 // Registers a stream, and sets its URL. 26 // Registers a stream, and sets its URL.
27 void RegisterStream(scoped_refptr<Stream> stream); 27 void RegisterStream(scoped_refptr<Stream> stream);
28 28
29 // Clones a stream. Returns true on success, or false if |src_url| doesn't 29 // Clones a stream. Returns true on success, or false if |src_url| doesn't
30 // exist. 30 // exist.
31 bool CloneStream(const GURL& url, const GURL& src_url); 31 bool CloneStream(const GURL& url, const GURL& src_url);
32 32
33 void UnregisterStream(const GURL& url); 33 void UnregisterStream(const GURL& url);
34 34
35 // Called by Stream instances to request increase of memory usage. If the
36 // total memory usage for this registry is going to exceed the limit,
37 // returns false. Otherwise, updates |total_memory_usage_| and returns true.
38 bool UpdateMemoryUsage(const GURL& url, size_t new_size);
39
35 // Gets the stream associated with |url|. Returns NULL if there is no such 40 // Gets the stream associated with |url|. Returns NULL if there is no such
36 // stream. 41 // stream.
37 scoped_refptr<Stream> GetStream(const GURL& url); 42 scoped_refptr<Stream> GetStream(const GURL& url);
38 43
44 // Only for testing.
45 void set_max_memory_usage(size_t size) {
Charlie Reis 2013/08/20 22:24:52 We usually end such method names with _for_testing
tyoshino (SeeGerritForStatus) 2013/08/21 05:37:28 Done.
46 max_memory_usage_ = size;
47 }
48
39 private: 49 private:
40 typedef std::map<GURL, scoped_refptr<Stream> > StreamMap; 50 typedef std::map<GURL, scoped_refptr<Stream> > StreamMap;
41 51
42 StreamMap streams_; 52 StreamMap streams_;
43 53
54 size_t total_memory_usage_;
55
56 // Maximum amount of memory allowed to use for Stream instances registered
57 // with this 5Aregistry.
Charlie Reis 2013/08/20 22:24:52 Is 5Aregistry a typo?
tyoshino (SeeGerritForStatus) 2013/08/21 05:37:28 Yes.. Fixed.
58 size_t max_memory_usage_;
59
44 DISALLOW_COPY_AND_ASSIGN(StreamRegistry); 60 DISALLOW_COPY_AND_ASSIGN(StreamRegistry);
45 }; 61 };
46 62
47 } // namespace content 63 } // namespace content
48 64
49 #endif // CONTENT_BROWSER_STREAMS_STREAM_REGISTRY_H_ 65 #endif // CONTENT_BROWSER_STREAMS_STREAM_REGISTRY_H_
50
51
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698