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
   48

content / public / test / test_fileapi_operation_waiter.h [blame]

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_PUBLIC_TEST_TEST_FILEAPI_OPERATION_WAITER_H_
#define CONTENT_PUBLIC_TEST_TEST_FILEAPI_OPERATION_WAITER_H_

#include <stdint.h>

#include "base/files/file.h"
#include "base/run_loop.h"
#include "storage/browser/file_system/file_observers.h"
#include "third_party/blink/public/mojom/filesystem/file_system.mojom.h"

namespace content {

// Installs a temporary storage::FileUpdateObserver for use in browser tests
// that need to wait for a specific fileapi operation to complete.
class TestFileapiOperationWaiter
    : public blink::mojom::FileSystemOperationListener {
 public:
  TestFileapiOperationWaiter();

  TestFileapiOperationWaiter(const TestFileapiOperationWaiter&) = delete;
  TestFileapiOperationWaiter& operator=(const TestFileapiOperationWaiter&) =
      delete;

  ~TestFileapiOperationWaiter() override;

  void WaitForOperationToFinish();

  // Callback for passing into blink::mojom::FileSystem::Create.
  void DidCreate(base::File::Error error_code);

  // blink::mojom::FileSystemOperationListener
  void ResultsRetrieved(
      std::vector<filesystem::mojom::DirectoryEntryPtr> entries,
      bool has_more) override;
  void ErrorOccurred(base::File::Error error_code) override;
  void DidWrite(int64_t byte_count, bool complete) override;

 private:
  base::RunLoop run_loop_;
};

}  // namespace content

#endif  // CONTENT_PUBLIC_TEST_TEST_FILEAPI_OPERATION_WAITER_H_