Index: headless/lib/headless_browser_impl.h |
diff --git a/headless/lib/headless_browser_impl.h b/headless/lib/headless_browser_impl.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2c08460b6248a2c7822ade24f77343d5ee447ba2 |
--- /dev/null |
+++ b/headless/lib/headless_browser_impl.h |
@@ -0,0 +1,71 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef HEADLESS_LIB_HEADLESS_BROWSER_IMPL_H_ |
+#define HEADLESS_LIB_HEADLESS_BROWSER_IMPL_H_ |
+ |
+#include "headless/public/headless_browser.h" |
+ |
+#include "base/memory/scoped_ptr.h" |
+#include "base/synchronization/lock.h" |
+#include "headless/lib/web_contents_impl.h" |
+ |
+namespace headless { |
+ |
+class HeadlessBrowserContext; |
+class HeadlessBrowserMainParts; |
+ |
+class HeadlessBrowserImpl : public HeadlessBrowser { |
+ public: |
+ static HeadlessBrowserImpl* Get(); |
+ |
+ // HeadlessBrowser implementation |
+ scoped_ptr<WebContents> CreateWebContents(const gfx::Size& size) override; |
+ scoped_refptr<base::SingleThreadTaskRunner> browser_main_thread() override; |
+ scoped_refptr<base::SingleThreadTaskRunner> renderer_main_thread() override; |
+ int Run(const Options& options, |
+ const base::Closure& on_browser_start_callback) override; |
+ void Stop() override; |
+ void StartTracing(const base::trace_event::TraceConfig& trace_config, |
+ const base::Closure& tracing_started_callback) override; |
+ void StopTracing(const std::string& log_file_name, |
+ const base::Closure& tracing_stopped_callback) override; |
+ |
+ HeadlessBrowserContext* browser_context(); |
+ |
+ HeadlessBrowserMainParts* browser_main_parts(); |
+ void set_browser_main_parts(HeadlessBrowserMainParts* browser_main_parts); |
+ |
+ void RunOnStartCallback(); |
+ |
+ void DidFinishWritingTrace(const base::Closure& tracing_stopped_callback); |
+ |
+ protected: |
+ friend class HeadlessBrowser; |
+ |
+ HeadlessBrowserImpl(); |
+ ~HeadlessBrowserImpl() override; |
+ |
+ // Should be called on main thread only. Use PostShutdownTask() to do it from |
+ // any other thread. |
+ void Shutdown(); |
+ |
+ void PostShutdownTask(); |
+ |
+ std::vector<scoped_ptr<WebContentsImpl>> web_contents_; |
+ |
+ scoped_refptr<base::SingleThreadTaskRunner> browser_main_thread_; |
+ scoped_refptr<base::SingleThreadTaskRunner> renderer_main_thread_; |
+ |
+ HeadlessBrowserMainParts* browser_main_parts_; |
+ |
+ scoped_ptr<base::Closure> on_start_callback_; |
+ |
+ base::Lock is_writing_trace_lock_; |
+ bool is_writing_trace_; |
+}; |
+ |
+} // namespace headless |
+ |
+#endif // HEADLESS_LIB_HEADLESS_BROWSER_IMPL_H_ |