summaryrefslogtreecommitdiffstats
path: root/mojo/shell/run.cc
blob: 0f25e2aca2ee83ed223a32209a592d59ba2075b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright 2013 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.

#include "mojo/shell/run.h"

#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "mojo/loader/loader.h"
#include "mojo/shell/app_container.h"
#include "mojo/shell/storage.h"
#include "mojo/shell/switches.h"
#include "mojo/shell/task_runners.h"
#include "mojo/system/core_impl.h"
#include "url/gurl.h"

namespace mojo {
namespace shell {

void Run() {
  system::CoreImpl::Init();

  // TODO(abarth): Group these objects into a "context" object.
  TaskRunners task_runners(base::MessageLoop::current()->message_loop_proxy());
  Storage storage;

  const CommandLine& command_line = *CommandLine::ForCurrentProcess();
  if (!command_line.HasSwitch(switches::kApp)) {
    LOG(ERROR) << "No app path specified.";
    return;
  }

  loader::Loader loader(task_runners.io_runner(),
                        task_runners.file_runner(),
                        storage.profile_path());

  scoped_ptr<AppContainer> container(new AppContainer);

  scoped_ptr<loader::Job> job = loader.Load(
    GURL(command_line.GetSwitchValueASCII(switches::kApp)),
    container.get());
}

}  // namespace shell
}  // namespace mojo