Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Unified Diff: headless/lib/browser/headless_browser_context_impl.h

Issue 2181413002: [headless] Remove default browser context. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More fixes Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: headless/lib/browser/headless_browser_context_impl.h
diff --git a/headless/lib/browser/headless_browser_context_impl.h b/headless/lib/browser/headless_browser_context_impl.h
index fae8f8a86334d1d0af05333ac7814af2491241e1..da7ab5916f3275dc010a77facf0a1a2d34047ea9 100644
--- a/headless/lib/browser/headless_browser_context_impl.h
+++ b/headless/lib/browser/headless_browser_context_impl.h
@@ -6,28 +6,38 @@
#define HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_IMPL_H_
#include <memory>
+#include <string>
+#include <unordered_map>
+#include <vector>
#include "base/files/file_path.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/resource_context.h"
+#include "headless/lib/browser/headless_browser_context_options.h"
#include "headless/lib/browser/headless_url_request_context_getter.h"
#include "headless/public/headless_browser.h"
#include "headless/public/headless_browser_context.h"
namespace headless {
+class HeadlessBrowserImpl;
class HeadlessResourceContext;
+class HeadlessWebContentsImpl;
class HeadlessBrowserContextImpl : public HeadlessBrowserContext,
public content::BrowserContext {
public:
- explicit HeadlessBrowserContextImpl(ProtocolHandlerMap protocol_handlers,
- HeadlessBrowser::Options* options);
+ HeadlessBrowserContextImpl(HeadlessBrowserImpl* browser,
+ HeadlessBrowserContextOptions context_options);
~HeadlessBrowserContextImpl() override;
static HeadlessBrowserContextImpl* From(
HeadlessBrowserContext* browser_context);
+ // HeadlessBrowserContext implementation:
+ HeadlessWebContents::Builder CreateWebContentsBuilder() override;
+ std::vector<HeadlessWebContents*> GetAllWebContents() override;
+
// BrowserContext implementation:
std::unique_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate(
const base::FilePath& partition_path) override;
@@ -54,19 +64,27 @@ class HeadlessBrowserContextImpl : public HeadlessBrowserContext,
const base::FilePath& partition_path,
bool in_memory) override;
- HeadlessBrowser::Options* options() const { return options_; }
- void SetOptionsForTesting(HeadlessBrowser::Options* options);
+ void RegisterWebContents(HeadlessWebContentsImpl*);
+ void UnregisterWebContents(HeadlessWebContentsImpl*);
+
+ HeadlessBrowserImpl* browser() const;
+ const HeadlessBrowserContextOptions* options() const;
private:
// Performs initialization of the HeadlessBrowserContextImpl while IO is still
// allowed on the current thread.
void InitWhileIOAllowed();
- ProtocolHandlerMap protocol_handlers_;
- HeadlessBrowser::Options* options_; // Not owned.
+ HeadlessBrowserImpl* browser_; // Not owned.
+ HeadlessBrowserContextOptions context_options_;
std::unique_ptr<HeadlessResourceContext> resource_context_;
base::FilePath path_;
+ // Web contents are owned by |HeadlessBrowser|, we keep track of
+ // contents corresponding to this context to delete them when context goes
+ // away.
+ std::unordered_map<std::string, HeadlessWebContents*> web_contents_map_;
+
DISALLOW_COPY_AND_ASSIGN(HeadlessBrowserContextImpl);
};

Powered by Google App Engine
This is Rietveld 408576698