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_CHROME_STREAM_CONTEXT_H_ |
| 6 #define CONTENT_BROWSER_STREAMS_CHROME_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 ChromeStreamContextDeleter; |
| 15 class ChromeStreamRegistry; |
| 16 |
| 17 // A context class that keeps track of ChromeStreamRegistry 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 ChromeStreamContext |
| 25 : public base::RefCountedThreadSafe<ChromeStreamContext, |
| 26 ChromeStreamContextDeleter> { |
| 27 public: |
| 28 ChromeStreamContext(); |
| 29 |
| 30 static ChromeStreamContext* GetFor(BrowserContext* browser_context); |
| 31 |
| 32 void InitializeOnIOThread(); |
| 33 |
| 34 ChromeStreamRegistry* registry() const { return registry_.get(); } |
| 35 |
| 36 protected: |
| 37 virtual ~ChromeStreamContext(); |
| 38 |
| 39 private: |
| 40 friend class base::DeleteHelper<ChromeStreamContext>; |
| 41 friend class base::RefCountedThreadSafe<ChromeStreamContext, |
| 42 ChromeStreamContextDeleter>; |
| 43 friend struct ChromeStreamContextDeleter; |
| 44 |
| 45 void DeleteOnCorrectThread() const; |
| 46 |
| 47 scoped_ptr<ChromeStreamRegistry> registry_; |
| 48 }; |
| 49 |
| 50 struct ChromeStreamContextDeleter { |
| 51 static void Destruct(const ChromeStreamContext* context) { |
| 52 context->DeleteOnCorrectThread(); |
| 53 } |
| 54 }; |
| 55 |
| 56 } // namespace content |
| 57 |
| 58 #endif // CONTENT_BROWSER_STREAMS_CHROME_STREAM_CONTEXT_H_ |
| 59 |
OLD | NEW |