summaryrefslogtreecommitdiffstats
path: root/webkit/blob/mock_blob_url_request_context.h
blob: b89027c95e7c07c3ced8acb550a9cef39448c32c (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
50
51
52
// 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_BLOB_MOCK_BLOB_URL_REQUEST_CONTEXT_H_
#define WEBKIT_BLOB_MOCK_BLOB_URL_REQUEST_CONTEXT_H_

#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_job.h"
#include "net/url_request/url_request_job_factory_impl.h"

namespace fileapi {
class FileSystemContext;
}

namespace webkit_blob {

class BlobStorageController;

class MockBlobURLRequestContext : public net::URLRequestContext {
 public:
  MockBlobURLRequestContext(fileapi::FileSystemContext* file_system_context);
  virtual ~MockBlobURLRequestContext();

  BlobStorageController* blob_storage_controller() const {
    return blob_storage_controller_.get();
  }

 private:
  net::URLRequestJobFactoryImpl job_factory_;
  scoped_ptr<BlobStorageController> blob_storage_controller_;

  DISALLOW_COPY_AND_ASSIGN(MockBlobURLRequestContext);
};

class ScopedTextBlob {
 public:
  ScopedTextBlob(const MockBlobURLRequestContext& request_context,
                 const GURL& blob_url,
                 const std::string& data);
  ~ScopedTextBlob();

 private:
  const GURL blob_url_;
  BlobStorageController* blob_storage_controller_;

  DISALLOW_COPY_AND_ASSIGN(ScopedTextBlob);
};

}  // namespace webkit_blob

#endif  // WEBKIT_BLOB_MOCK_BLOB_URL_REQUEST_CONTEXT_H_