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 IOS_CHROME_BROWSER_NET_IOS_CHROME_URL_REQUEST_CONTEXT_GETTER_H_ | 5 #ifndef IOS_CHROME_BROWSER_NET_IOS_CHROME_URL_REQUEST_CONTEXT_GETTER_H_ |
6 #define IOS_CHROME_BROWSER_NET_IOS_CHROME_URL_REQUEST_CONTEXT_GETTER_H_ | 6 #define IOS_CHROME_BROWSER_NET_IOS_CHROME_URL_REQUEST_CONTEXT_GETTER_H_ |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "ios/chrome/browser/net/net_types.h" | 11 #include "ios/chrome/browser/net/net_types.h" |
11 #include "net/url_request/url_request_context.h" | 12 #include "net/url_request/url_request_context.h" |
12 #include "net/url_request/url_request_context_getter.h" | 13 #include "net/url_request/url_request_context_getter.h" |
13 | 14 |
14 class ChromeBrowserStateIOData; | 15 class ChromeBrowserStateIOData; |
15 class IOSChromeURLRequestContextFactory; | 16 class IOSChromeURLRequestContextFactory; |
16 | 17 |
17 // A net::URLRequestContextGetter subclass used by the browser. This returns a | 18 // A net::URLRequestContextGetter subclass used by the browser. This returns a |
18 // subclass of net::URLRequestContext which can be used to store extra | 19 // subclass of net::URLRequestContext which can be used to store extra |
19 // information about requests. | 20 // information about requests. |
20 // | 21 // |
21 // Most methods are expected to be called on the UI thread, except for | 22 // Most methods are expected to be called on the UI thread, except for |
22 // the destructor and GetURLRequestContext(). | 23 // the destructor and GetURLRequestContext(). |
23 class IOSChromeURLRequestContextGetter : public net::URLRequestContextGetter { | 24 class IOSChromeURLRequestContextGetter : public net::URLRequestContextGetter { |
24 public: | 25 public: |
25 // Constructs a ChromeURLRequestContextGetter that will use |factory| to | 26 // Constructs a ChromeURLRequestContextGetter that will use |factory| to |
26 // create the URLRequestContext. | 27 // create the URLRequestContext. |
27 explicit IOSChromeURLRequestContextGetter( | 28 explicit IOSChromeURLRequestContextGetter( |
28 scoped_ptr<IOSChromeURLRequestContextFactory> factory); | 29 std::unique_ptr<IOSChromeURLRequestContextFactory> factory); |
29 | 30 |
30 // Note that GetURLRequestContext() can only be called from the IO | 31 // Note that GetURLRequestContext() can only be called from the IO |
31 // thread (it will assert otherwise). | 32 // thread (it will assert otherwise). |
32 // GetIOMessageLoopProxy however can be called from any thread. | 33 // GetIOMessageLoopProxy however can be called from any thread. |
33 // | 34 // |
34 // net::URLRequestContextGetter implementation. | 35 // net::URLRequestContextGetter implementation. |
35 net::URLRequestContext* GetURLRequestContext() override; | 36 net::URLRequestContext* GetURLRequestContext() override; |
36 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() | 37 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() |
37 const override; | 38 const override; |
38 | 39 |
(...skipping 12 matching lines...) Expand all Loading... |
51 | 52 |
52 // Discard reference to URLRequestContext and inform observers of shutdown. | 53 // Discard reference to URLRequestContext and inform observers of shutdown. |
53 // Must be called before destruction. May only be called on IO thread. | 54 // Must be called before destruction. May only be called on IO thread. |
54 void NotifyContextShuttingDown(); | 55 void NotifyContextShuttingDown(); |
55 | 56 |
56 private: | 57 private: |
57 ~IOSChromeURLRequestContextGetter() override; | 58 ~IOSChromeURLRequestContextGetter() override; |
58 | 59 |
59 // Deferred logic for creating a URLRequestContext. | 60 // Deferred logic for creating a URLRequestContext. |
60 // Access only from the IO thread. | 61 // Access only from the IO thread. |
61 scoped_ptr<IOSChromeURLRequestContextFactory> factory_; | 62 std::unique_ptr<IOSChromeURLRequestContextFactory> factory_; |
62 | 63 |
63 // NULL before initialization and after invalidation. | 64 // NULL before initialization and after invalidation. |
64 // Otherwise, it is the URLRequestContext instance that | 65 // Otherwise, it is the URLRequestContext instance that |
65 // was lazily created by GetURLRequestContext(). | 66 // was lazily created by GetURLRequestContext(). |
66 // Access only from the IO thread. | 67 // Access only from the IO thread. |
67 net::URLRequestContext* url_request_context_; | 68 net::URLRequestContext* url_request_context_; |
68 | 69 |
69 DISALLOW_COPY_AND_ASSIGN(IOSChromeURLRequestContextGetter); | 70 DISALLOW_COPY_AND_ASSIGN(IOSChromeURLRequestContextGetter); |
70 }; | 71 }; |
71 | 72 |
72 #endif // IOS_CHROME_BROWSER_NET_IOS_CHROME_URL_REQUEST_CONTEXT_GETTER_H_ | 73 #endif // IOS_CHROME_BROWSER_NET_IOS_CHROME_URL_REQUEST_CONTEXT_GETTER_H_ |
OLD | NEW |