blob: 7ba9cbe1ccf2855c0c2d111b47340509e22ba4dc (
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
|
// 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.
#include "content/public/test/mock_blob_url_request_context.h"
#include "base/thread_task_runner_handle.h"
#include "storage/browser/blob/blob_data_builder.h"
#include "storage/browser/blob/blob_storage_context.h"
#include "storage/browser/blob/blob_url_request_job.h"
#include "storage/browser/blob/blob_url_request_job_factory.h"
namespace content {
MockBlobURLRequestContext::MockBlobURLRequestContext(
storage::FileSystemContext* file_system_context)
: blob_storage_context_(new storage::BlobStorageContext) {
// Job factory owns the protocol handler.
job_factory_.SetProtocolHandler(
"blob", make_scoped_ptr(new storage::BlobProtocolHandler(
blob_storage_context_.get(), file_system_context,
base::ThreadTaskRunnerHandle::Get())));
set_job_factory(&job_factory_);
}
MockBlobURLRequestContext::~MockBlobURLRequestContext() {
AssertNoURLRequests();
}
ScopedTextBlob::ScopedTextBlob(
const MockBlobURLRequestContext& request_context,
const std::string& blob_id,
const std::string& data)
: blob_id_(blob_id),
context_(request_context.blob_storage_context()) {
DCHECK(context_);
storage::BlobDataBuilder blob_builder(blob_id_);
if (!data.empty())
blob_builder.AppendData(data);
handle_ = context_->AddFinishedBlob(&blob_builder);
}
ScopedTextBlob::~ScopedTextBlob() {
}
scoped_ptr<storage::BlobDataHandle> ScopedTextBlob::GetBlobDataHandle() {
return context_->GetBlobDataFromUUID(blob_id_);
}
} // namespace content
|