Skip to content

Commit

Permalink
[Blimp] Adds Blimp EngineSession and ClientSession skeleton.
Browse files Browse the repository at this point in the history
BlimpClientSessionManager (to be added) authenticates and creates client sessions. Once a client session is authenticated, it is given to the engine session. There is at most one active client session attached to the engine session.

The engine session manages a list of web contents.

Review URL: https://codereview.chromium.org/1403083002

Cr-Commit-Position: refs/heads/master@{#354388}
  • Loading branch information
haibinlu authored and Commit bot committed Oct 15, 2015
1 parent 2ae73f1 commit 28516c7
Show file tree
Hide file tree
Showing 20 changed files with 361 additions and 349 deletions.
3 changes: 1 addition & 2 deletions blimp/common/proto/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ group("proto") {
proto_library("proto_lib") {
sources = [
"blimp_message.proto",
"client_control.proto",
"common.proto",
"compositor.proto",
"control.proto",
"input.proto",
"server_control.proto",
]
}
9 changes: 3 additions & 6 deletions blimp/common/proto/blimp_message.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,17 @@ syntax = "proto2";

option optimize_for = LITE_RUNTIME;

import "client_control.proto";
import "control.proto";
import "compositor.proto";
import "input.proto";
import "server_control.proto";

package blimp;

message BlimpMessage {
enum Type {
COMPOSITOR = 0;
INPUT = 1;
CLIENT_CONTROL = 2;
SERVER_CONTROL = 3;
CONTROL = 2;
}
// Identifies the feature type of this message.
// The feature-specific contents are contained in optional fields of the same
Expand All @@ -59,7 +57,6 @@ message BlimpMessage {
// TODO(kmarshall): use a 'oneof' union when it's supported in Chromium.
optional CompositorMessage compositor = 1000;
optional InputMessage input = 1001;
optional ClientControlMessage client_control = 1002;
optional ServerControlMessage server_control = 1003;
optional ControlMessage control = 1002;
}

29 changes: 0 additions & 29 deletions blimp/common/proto/client_control.proto

This file was deleted.

28 changes: 28 additions & 0 deletions blimp/common/proto/control.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// 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.
//
// Message definitions for browser control messages.

syntax = "proto2";

option optimize_for = LITE_RUNTIME;

message LoadUrlMessage {
optional string url = 1;
}

message ControlMessage {
enum Type {
// Client <=> Server types.
CREATE_TAB = 1;
CLOSE_TAB = 2;
LOAD_URL = 3;

// Server => Client types.
// Client => Server types.
}
optional Type type = 1;

optional LoadUrlMessage load_url = 1000;
}
43 changes: 0 additions & 43 deletions blimp/common/proto/server_control.proto

This file was deleted.

6 changes: 4 additions & 2 deletions blimp/engine/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ source_set("browser") {
"blimp_browser_main_parts.h",
"blimp_content_browser_client.cc",
"blimp_content_browser_client.h",
"blimp_engine_session.cc",
"blimp_engine_session.h",
"blimp_network_delegate.cc",
"blimp_network_delegate.h",
"blimp_permission_manager.cc",
"blimp_permission_manager.h",
"blimp_url_request_context_getter.cc",
"blimp_url_request_context_getter.h",
"blimp_window.cc",
"blimp_window.h",
]

deps = [
"//base",
"//blimp/common/proto",
"//blimp/net:blimp_net",
"//blimp/engine/ui",
"//content",
"//content/public/browser",
Expand Down
48 changes: 15 additions & 33 deletions blimp/engine/browser/blimp_browser_main_parts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,57 +4,39 @@

#include "blimp/engine/browser/blimp_browser_main_parts.h"

#include "base/command_line.h"
#include "blimp/engine/browser/blimp_window.h"
#include "blimp/engine/ui/blimp_screen.h"
#include "blimp/engine/browser/blimp_browser_context.h"
#include "blimp/engine/browser/blimp_engine_session.h"
#include "blimp/net/blimp_client_session.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/main_function_params.h"
#include "net/base/net_module.h"
#include "net/log/net_log.h"
#include "url/gurl.h"

namespace blimp {
namespace engine {

namespace {

const char kDefaultURL[] = "https://www.google.com/";

GURL GetStartupURL() {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
const base::CommandLine::StringVector& args = command_line->GetArgs();
if (args.empty())
return GURL(kDefaultURL);

GURL url(args[0]);
if (url.is_valid() && url.has_scheme())
return url;

return GURL(kDefaultURL);
}

} // namespace

BlimpBrowserMainParts::BlimpBrowserMainParts(
const content::MainFunctionParams& parameters) {}

BlimpBrowserMainParts::~BlimpBrowserMainParts() {}

void BlimpBrowserMainParts::PreMainMessageLoopRun() {
net_log_.reset(new net::NetLog());
browser_context_.reset(new BlimpBrowserContext(false, net_log_.get()));
BlimpWindow::Create(browser_context_.get(), GetStartupURL(), nullptr,
gfx::Size());
scoped_ptr<BlimpBrowserContext> browser_context(
new BlimpBrowserContext(false, net_log_.get()));
engine_session_.reset(new BlimpEngineSession(browser_context.Pass()));
engine_session_->Initialize();
// TODO(haibinlu): remove this after a real client session can be attached.
scoped_ptr<BlimpClientSession> startupSession(new BlimpClientSession);
engine_session_->AttachClientSession(startupSession.Pass());
}

int BlimpBrowserMainParts::PreCreateThreads() {
screen_.reset(new BlimpScreen);
DCHECK(!gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE));
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get());
return 0;
void BlimpBrowserMainParts::PostMainMessageLoopRun() {
engine_session_.reset();
}

void BlimpBrowserMainParts::PostMainMessageLoopRun() {
browser_context_.reset();
BlimpBrowserContext* BlimpBrowserMainParts::GetBrowserContext() {
return engine_session_->browser_context();
}

} // namespace engine
Expand Down
14 changes: 8 additions & 6 deletions blimp/engine/browser/blimp_browser_main_parts.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@

#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "blimp/engine/browser/blimp_browser_context.h"
#include "content/public/browser/browser_main_parts.h"

namespace net {
class NetLog;
}

namespace content {
struct MainFunctionParams;
}

namespace blimp {
namespace engine {

class BlimpScreen;
class BlimpBrowserContext;
class BlimpEngineSession;

class BlimpBrowserMainParts : public content::BrowserMainParts {
public:
Expand All @@ -27,14 +31,12 @@ class BlimpBrowserMainParts : public content::BrowserMainParts {
// content::BrowserMainParts implementation.
void PreMainMessageLoopRun() override;
void PostMainMessageLoopRun() override;
int PreCreateThreads() override;

BlimpBrowserContext* browser_context() { return browser_context_.get(); }
BlimpBrowserContext* GetBrowserContext();

private:
scoped_ptr<net::NetLog> net_log_;
scoped_ptr<BlimpBrowserContext> browser_context_;
scoped_ptr<BlimpScreen> screen_;
scoped_ptr<BlimpEngineSession> engine_session_;

DISALLOW_COPY_AND_ASSIGN(BlimpBrowserMainParts);
};
Expand Down
4 changes: 2 additions & 2 deletions blimp/engine/browser/blimp_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ net::URLRequestContextGetter* BlimpContentBrowserClient::CreateRequestContext(
.get();
}

BlimpBrowserContext* BlimpContentBrowserClient::browser_context() {
return blimp_browser_main_parts_->browser_context();
BlimpBrowserContext* BlimpContentBrowserClient::GetBrowserContext() {
return blimp_browser_main_parts_->GetBrowserContext();
}

} // namespace engine
Expand Down
2 changes: 1 addition & 1 deletion blimp/engine/browser/blimp_content_browser_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class BlimpContentBrowserClient : public content::ContentBrowserClient {
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors) override;

BlimpBrowserContext* browser_context();
BlimpBrowserContext* GetBrowserContext();

private:
// Owned by BrowserMainLoop
Expand Down
Loading

0 comments on commit 28516c7

Please sign in to comment.