1eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch// Copyright 2013 The Chromium Authors. All rights reserved.
2eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch// Use of this source code is governed by a BSD-style license that can be
3eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch// found in the LICENSE file.
4eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
5eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#ifndef CHROME_BROWSER_COMPONENT_UPDATER_TEST_TEST_INSTALLER_H_
6eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#define CHROME_BROWSER_COMPONENT_UPDATER_TEST_TEST_INSTALLER_H_
7eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
8010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)#include <string>
9010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)
10eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "base/compiler_specific.h"
11eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "base/files/file_path.h"
1203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)#include "components/component_updater/component_updater_service.h"
13eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
14eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdochnamespace base {
15eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdochclass DictionaryValue;
16eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch}
17eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace component_updater {
195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
20eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch// A TestInstaller is an installer that does nothing for installation except
21eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch// increment a counter.
22eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdochclass TestInstaller : public ComponentInstaller {
23eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch public:
2403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  TestInstaller();
25eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
26eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  virtual void OnUpdateError(int error) OVERRIDE;
27eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
28eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  virtual bool Install(const base::DictionaryValue& manifest,
29eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch                       const base::FilePath& unpack_path) OVERRIDE;
30eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
31eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  virtual bool GetInstalledFile(const std::string& file,
32eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch                                base::FilePath* installed_file) OVERRIDE;
33eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
34eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  int error() const;
35eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
36eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  int install_count() const;
37eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
38eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch protected:
39eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  int error_;
40eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  int install_count_;
41eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch};
42eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
43eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch// A ReadOnlyTestInstaller is an installer that knows about files in an existing
44eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch// directory. It will not write to the directory.
45eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdochclass ReadOnlyTestInstaller : public TestInstaller {
46eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch public:
47eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  explicit ReadOnlyTestInstaller(const base::FilePath& installed_path);
48eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
49eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  virtual ~ReadOnlyTestInstaller();
50eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
51eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  virtual bool GetInstalledFile(const std::string& file,
52eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch                                base::FilePath* installed_file) OVERRIDE;
53eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
54eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch private:
55eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  base::FilePath install_directory_;
56eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch};
57eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
58eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch// A VersionedTestInstaller is an installer that installs files into versioned
59eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch// directories (e.g. somedir/25.23.89.141/<files>).
60eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdochclass VersionedTestInstaller : public TestInstaller {
61010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) public:
6203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  VersionedTestInstaller();
63eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
64eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  virtual ~VersionedTestInstaller();
65eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
66eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  virtual bool Install(const base::DictionaryValue& manifest,
67eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch                       const base::FilePath& unpack_path) OVERRIDE;
68eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
69eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  virtual bool GetInstalledFile(const std::string& file,
70eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch                                base::FilePath* installed_file) OVERRIDE;
71eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
72eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch private:
73eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  base::FilePath install_directory_;
74eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  Version current_version_;
75eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch};
76eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}  // namespace component_updater
785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
79eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#endif  // CHROME_BROWSER_COMPONENT_UPDATER_TEST_TEST_INSTALLER_H_
80