io_thread.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright (c) 2017 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ATOM_BROWSER_IO_THREAD_H_
  5. #define ATOM_BROWSER_IO_THREAD_H_
  6. #include <memory>
  7. #include "base/macros.h"
  8. #include "base/memory/scoped_refptr.h"
  9. #include "content/public/browser/browser_thread_delegate.h"
  10. namespace net {
  11. class URLRequestContext;
  12. class URLRequestContextGetter;
  13. } // namespace net
  14. namespace net_log {
  15. class ChromeNetLog;
  16. }
  17. namespace atom {
  18. class IOThread : public content::BrowserThreadDelegate {
  19. public:
  20. explicit IOThread(net_log::ChromeNetLog* net_log);
  21. ~IOThread() override;
  22. net::URLRequestContextGetter* GetRequestContext() {
  23. return url_request_context_getter_.get();
  24. }
  25. protected:
  26. // BrowserThreadDelegate Implementation, runs on the IO thread.
  27. void Init() override;
  28. void CleanUp() override;
  29. private:
  30. // The NetLog is owned by the browser process, to allow logging from other
  31. // threads during shutdown, but is used most frequently on the IOThread.
  32. net_log::ChromeNetLog* net_log_;
  33. std::unique_ptr<net::URLRequestContext> url_request_context_;
  34. scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
  35. DISALLOW_COPY_AND_ASSIGN(IOThread);
  36. };
  37. } // namespace atom
  38. #endif // ATOM_BROWSER_IO_THREAD_H_