summaryrefslogtreecommitdiffstats
path: root/webkit/support/test_shell_webblobregistry_impl.h
blob: 278ee1cca6dc491874b8da05f3a464e511e150d9 (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
48
49
// 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.

#ifndef WEBKIT_SUPPORT_TEST_SHELL_WEBBLOBREGISTRY_IMPL_H_
#define WEBKIT_SUPPORT_TEST_SHELL_WEBBLOBREGISTRY_IMPL_H_

#include "base/memory/ref_counted.h"
#include "third_party/WebKit/public/platform/WebBlobRegistry.h"

class GURL;

namespace webkit_blob {
class BlobData;
class BlobStorageController;
}

class TestShellWebBlobRegistryImpl
    : public WebKit::WebBlobRegistry,
      public base::RefCountedThreadSafe<TestShellWebBlobRegistryImpl> {
 public:
  static void InitializeOnIOThread(
      webkit_blob::BlobStorageController* blob_storage_controller);
  static void Cleanup();

  TestShellWebBlobRegistryImpl();

  // See WebBlobRegistry.h for documentation on these functions.
  virtual void registerBlobURL(const WebKit::WebURL& url,
                               WebKit::WebBlobData& data);
  virtual void registerBlobURL(const WebKit::WebURL& url,
                               const WebKit::WebURL& src_url);
  virtual void unregisterBlobURL(const WebKit::WebURL& url);

 protected:
  virtual ~TestShellWebBlobRegistryImpl() {}

 private:
  friend class base::RefCountedThreadSafe<TestShellWebBlobRegistryImpl>;

  // Run on I/O thread.
  void AddFinishedBlob(const GURL& url, webkit_blob::BlobData* blob_data);
  void CloneBlob(const GURL& url, const GURL& src_url);
  void RemoveBlob(const GURL& url);

  DISALLOW_COPY_AND_ASSIGN(TestShellWebBlobRegistryImpl);
};

#endif  // WEBKIT_SUPPORT_TEST_SHELL_WEBBLOBREGISTRY_IMPL_H_