| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 CHROME_COMMON_NET_URL_REQUEST_CONTEXT_GETTER_H_ | 5 #ifndef CHROME_COMMON_NET_URL_REQUEST_CONTEXT_GETTER_H_ |
| 6 #define CHROME_COMMON_NET_URL_REQUEST_CONTEXT_GETTER_H_ | 6 #define CHROME_COMMON_NET_URL_REQUEST_CONTEXT_GETTER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/ref_counted.h" | 9 #include "base/ref_counted.h" |
| 10 #include "base/task.h" | 10 #include "base/task.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 URLRequestContextGetterTraits> { | 26 URLRequestContextGetterTraits> { |
| 27 public: | 27 public: |
| 28 virtual URLRequestContext* GetURLRequestContext() = 0; | 28 virtual URLRequestContext* GetURLRequestContext() = 0; |
| 29 | 29 |
| 30 // Defaults to GetURLRequestContext()->cookie_store(), but | 30 // Defaults to GetURLRequestContext()->cookie_store(), but |
| 31 // implementations can override it. | 31 // implementations can override it. |
| 32 virtual net::CookieStore* GetCookieStore(); | 32 virtual net::CookieStore* GetCookieStore(); |
| 33 // Returns a MessageLoopProxy corresponding to the thread on which the | 33 // Returns a MessageLoopProxy corresponding to the thread on which the |
| 34 // request IO happens (the thread on which the returned URLRequestContext | 34 // request IO happens (the thread on which the returned URLRequestContext |
| 35 // may be used). | 35 // may be used). |
| 36 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() = 0; | 36 virtual scoped_refptr<base::MessageLoopProxy> |
| 37 GetIOMessageLoopProxy() const = 0; |
| 37 | 38 |
| 38 // Controls whether or not the URLRequestContextGetter considers itself to be | 39 // Controls whether or not the URLRequestContextGetter considers itself to be |
| 39 // the the "main" URLRequestContextGetter. Note that each Profile will have a | 40 // the the "main" URLRequestContextGetter. Note that each Profile will have a |
| 40 // "default" URLRequestContextGetter. Therefore, "is_main" refers to the | 41 // "default" URLRequestContextGetter. Therefore, "is_main" refers to the |
| 41 // default URLRequestContextGetter for the "main" Profile. | 42 // default URLRequestContextGetter for the "main" Profile. |
| 42 // TODO(willchan): Move this code to ChromeURLRequestContextGetter, since this | 43 // TODO(willchan): Move this code to ChromeURLRequestContextGetter, since this |
| 43 // ia a browser process specific concept. | 44 // ia a browser process specific concept. |
| 44 void set_is_main(bool is_main) { is_main_ = is_main; } | 45 void set_is_main(bool is_main) { is_main_ = is_main; } |
| 45 | 46 |
| 46 protected: | 47 protected: |
| 47 friend class DeleteTask<URLRequestContextGetter>; | 48 friend class DeleteTask<const URLRequestContextGetter>; |
| 48 friend struct URLRequestContextGetterTraits; | 49 friend struct URLRequestContextGetterTraits; |
| 49 | 50 |
| 50 URLRequestContextGetter(); | 51 URLRequestContextGetter(); |
| 51 virtual ~URLRequestContextGetter(); | 52 virtual ~URLRequestContextGetter(); |
| 52 | 53 |
| 53 bool is_main() const { return is_main_; } | 54 bool is_main() const { return is_main_; } |
| 54 | 55 |
| 55 private: | 56 private: |
| 56 // OnDestruct is meant to ensure deletion on the thread on which the request | 57 // OnDestruct is meant to ensure deletion on the thread on which the request |
| 57 // IO happens. | 58 // IO happens. |
| 58 void OnDestruct(); | 59 void OnDestruct() const; |
| 59 | 60 |
| 60 // Indicates whether or not this is the default URLRequestContextGetter for | 61 // Indicates whether or not this is the default URLRequestContextGetter for |
| 61 // the main Profile. | 62 // the main Profile. |
| 62 bool is_main_; | 63 bool is_main_; |
| 63 }; | 64 }; |
| 64 | 65 |
| 65 struct URLRequestContextGetterTraits { | 66 struct URLRequestContextGetterTraits { |
| 66 static void Destruct(URLRequestContextGetter* context_getter) { | 67 static void Destruct(const URLRequestContextGetter* context_getter) { |
| 67 context_getter->OnDestruct(); | 68 context_getter->OnDestruct(); |
| 68 } | 69 } |
| 69 }; | 70 }; |
| 70 | 71 |
| 71 #endif // CHROME_COMMON_NET_URL_REQUEST_CONTEXT_GETTER_H_ | 72 #endif // CHROME_COMMON_NET_URL_REQUEST_CONTEXT_GETTER_H_ |
| OLD | NEW |