summaryrefslogtreecommitdiffstats
path: root/components/sessions/base_session_service_test_helper.h
blob: a12fb0e74b6e741ca2fc8022e841f6a92c1bb2a1 (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
// Copyright 2014 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.

#ifndef COMPONENTS_SESSIONS_BASE_SESSION_SERVICE_TEST_HELPER_H_
#define COMPONENTS_SESSIONS_BASE_SESSION_SERVICE_TEST_HELPER_H_

#include "base/basictypes.h"
#include "base/callback.h"
#include "base/memory/scoped_vector.h"
#include "base/task/cancelable_task_tracker.h"

namespace sessions {
class SessionCommand;
class BaseSessionService;

class BaseSessionServiceTestHelper {
 public:
  explicit BaseSessionServiceTestHelper(
      BaseSessionService* base_session_service_);
  ~BaseSessionServiceTestHelper();

  // This posts the task to the SequencedWorkerPool, or run immediately
  // if the SequencedWorkerPool has been shutdown.
  void RunTaskOnBackendThread(const tracked_objects::Location& from_here,
                              const base::Closure& task);

  // Returns true if any commands got processed yet - saved or queued.
  bool ProcessedAnyCommands();

  // Read the last session commands directly from file.
  bool ReadLastSessionCommands(ScopedVector<SessionCommand>* commands);

 private:
  BaseSessionService* base_session_service_;

  DISALLOW_COPY_AND_ASSIGN(BaseSessionServiceTestHelper);
};

}  // namespace sessions

#endif  // COMPONENTS_SESSIONS_BASE_SESSION_SERVICE_TEST_HELPER_H_