OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_BROWSER_STREAMS_STREAM_CONTEXT_H_ | |
6 #define CONTENT_BROWSER_STREAMS_STREAM_CONTEXT_H_ | |
7 | |
8 #include "base/memory/ref_counted.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/sequenced_task_runner_helpers.h" | |
11 | |
12 namespace content { | |
13 class BrowserContext; | |
14 struct StreamContextDeleter; | |
15 class StreamRegistry; | |
16 | |
17 // A context class that keeps track of StreamRegistry used by the chrome. | |
18 // There is an instance associated with each BrowserContext. There could be | |
19 // multiple URLRequestContexts in the same browser context that refers to the | |
20 // same instance. | |
21 // | |
22 // All methods, except the ctor, are expected to be called on | |
23 // the IO thread (unless specifically called out in doc comments). | |
24 class StreamContext | |
25 : public base::RefCountedThreadSafe<StreamContext, | |
26 StreamContextDeleter> { | |
kinuko
2013/02/26 07:37:55
nit: while we're in content/ I think we can use so
Zachary Kuznia
2013/02/26 08:30:03
Done.
| |
27 public: | |
28 StreamContext(); | |
29 | |
30 static StreamContext* GetFor(BrowserContext* browser_context); | |
31 | |
32 void InitializeOnIOThread(); | |
33 | |
34 StreamRegistry* registry() const { return registry_.get(); } | |
35 | |
36 protected: | |
37 virtual ~StreamContext(); | |
38 | |
39 private: | |
40 friend class base::DeleteHelper<StreamContext>; | |
41 friend class base::RefCountedThreadSafe<StreamContext, StreamContextDeleter>; | |
42 friend struct StreamContextDeleter; | |
43 | |
44 void DeleteOnCorrectThread() const; | |
45 | |
46 scoped_ptr<StreamRegistry> registry_; | |
47 }; | |
48 | |
49 struct StreamContextDeleter { | |
50 static void Destruct(const StreamContext* context) { | |
51 context->DeleteOnCorrectThread(); | |
52 } | |
53 }; | |
54 | |
55 } // namespace content | |
56 | |
57 #endif // CONTENT_BROWSER_STREAMS_STREAM_CONTEXT_H_ | |
58 | |
OLD | NEW |