summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net/blob_url_request_job_factory.cc
blob: dab29d5f18778635a4344b488d42c7a6130f71c7 (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
// Copyright (c) 2010 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 "chrome/browser/net/blob_url_request_job_factory.h"

#include "chrome/browser/chrome_blob_storage_context.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/net/chrome_url_request_context.h"
#include "chrome/common/url_constants.h"
#include "webkit/blob/blob_storage_controller.h"
#include "webkit/blob/blob_url_request_job.h"

namespace {

URLRequestJob* BlobURLRequestJobFactory(URLRequest* request,
                                        const std::string& scheme) {
  webkit_blob::BlobStorageController* blob_storage_controller =
      static_cast<ChromeURLRequestContext*>(request->context())->
          blob_storage_context()->controller();
  return new webkit_blob::BlobURLRequestJob(
      request,
      blob_storage_controller->GetBlobDataFromUrl(request->url()),
      ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE));
}

}

void RegisterBlobURLRequestJobFactory() {
  URLRequest::RegisterProtocolFactory(chrome::kBlobScheme,
                                      &BlobURLRequestJobFactory);
}