shell_url_request_context_getter.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright 2014 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. #ifndef IOS_WEB_SHELL_SHELL_URL_REQUEST_CONTEXT_GETTER_H_
  5. #define IOS_WEB_SHELL_SHELL_URL_REQUEST_CONTEXT_GETTER_H_
  6. #include <memory>
  7. #include "base/compiler_specific.h"
  8. #include "base/files/file_path.h"
  9. #include "base/memory/ref_counted.h"
  10. #include "base/task/single_thread_task_runner.h"
  11. #include "net/url_request/url_request_context_getter.h"
  12. namespace net {
  13. class ProxyConfigService;
  14. class URLRequestContext;
  15. class SystemCookieStore;
  16. } // namespace net
  17. namespace web {
  18. class BrowserState;
  19. class ShellURLRequestContextGetter : public net::URLRequestContextGetter {
  20. public:
  21. ShellURLRequestContextGetter(
  22. const base::FilePath& base_path,
  23. web::BrowserState* browser_state,
  24. const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner);
  25. ShellURLRequestContextGetter(const ShellURLRequestContextGetter&) = delete;
  26. ShellURLRequestContextGetter& operator=(const ShellURLRequestContextGetter&) =
  27. delete;
  28. // net::URLRequestContextGetter implementation.
  29. net::URLRequestContext* GetURLRequestContext() override;
  30. scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner()
  31. const override;
  32. protected:
  33. ~ShellURLRequestContextGetter() override;
  34. private:
  35. base::FilePath base_path_;
  36. scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
  37. std::unique_ptr<net::ProxyConfigService> proxy_config_service_;
  38. std::unique_ptr<net::URLRequestContext> url_request_context_;
  39. // SystemCookieStore must be created on UI thread in
  40. // ShellURLRequestContextGetter's constructor. Later the ownership is passed
  41. // to net::URLRequestContextStorage on IO thread. |system_cookie_store_| is
  42. // created in constructor and cleared in GetURLRequestContext() where
  43. // net::URLRequestContextStorage is lazily created.
  44. std::unique_ptr<net::SystemCookieStore> system_cookie_store_;
  45. };
  46. } // namespace web
  47. #endif // IOS_WEB_SHELL_SHELL_URL_REQUEST_CONTEXT_GETTER_H_