summaryrefslogtreecommitdiffstats
path: root/chrome/test/chromedriver/chrome_impl.cc
blob: 04fe0cf0f0fb9f13950facd5bd0a5e43ffd2b2c2 (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
// Copyright (c) 2012 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 "chrome/test/chromedriver/chrome_impl.h"

#include "base/logging.h"
#include "base/process_util.h"
#include "chrome/test/chromedriver/status.h"

ChromeImpl::ChromeImpl(base::ProcessHandle process,
                       ScopedTempDir* user_data_dir)
    : process_(process) {
  if (user_data_dir->IsValid()) {
    CHECK(user_data_dir_.Set(user_data_dir->Take()));
  }
}

ChromeImpl::~ChromeImpl() {
  base::CloseProcessHandle(process_);
}

Status ChromeImpl::Quit() {
  if (!base::KillProcess(process_, 0, true))
    return Status(kUnknownError, "cannot kill Chrome");
  return Status(kOk);
}