Home | History | Annotate | Download | only in blob
      1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef WEBKIT_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_FACTORY_H_
      6 #define WEBKIT_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_FACTORY_H_
      7 
      8 #include "base/compiler_specific.h"
      9 #include "base/memory/ref_counted.h"
     10 #include "net/url_request/url_request_job_factory.h"
     11 #include "webkit/browser/webkit_storage_browser_export.h"
     12 
     13 namespace base {
     14 class MessageLoopProxy;
     15 }  // namespace base
     16 
     17 namespace fileapi {
     18 class FileSystemContext;
     19 }  // namespace fileapi
     20 
     21 namespace net {
     22 class URLRequest;
     23 }  // namespace net
     24 
     25 namespace webkit_blob {
     26 
     27 class BlobData;
     28 class BlobStorageController;
     29 
     30 class WEBKIT_STORAGE_BROWSER_EXPORT BlobProtocolHandler
     31     : public net::URLRequestJobFactory::ProtocolHandler {
     32  public:
     33   // |controller|'s lifetime should exceed the lifetime of the ProtocolHandler.
     34   BlobProtocolHandler(BlobStorageController* blob_storage_controller,
     35                       fileapi::FileSystemContext* file_system_context,
     36                       base::MessageLoopProxy* file_loop_proxy);
     37   virtual ~BlobProtocolHandler();
     38 
     39   virtual net::URLRequestJob* MaybeCreateJob(
     40       net::URLRequest* request,
     41       net::NetworkDelegate* network_delegate) const OVERRIDE;
     42 
     43  private:
     44   virtual scoped_refptr<BlobData> LookupBlobData(
     45       net::URLRequest* request) const;
     46 
     47   // No scoped_refptr because |blob_storage_controller_| is owned by the
     48   // ProfileIOData, which also owns this ProtocolHandler.
     49   BlobStorageController* const blob_storage_controller_;
     50   const scoped_refptr<fileapi::FileSystemContext> file_system_context_;
     51   const scoped_refptr<base::MessageLoopProxy> file_loop_proxy_;
     52 
     53   DISALLOW_COPY_AND_ASSIGN(BlobProtocolHandler);
     54 };
     55 
     56 }  // namespace webkit_blob
     57 
     58 #endif  // WEBKIT_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_FACTORY_H_
     59