url_request_job_factory.h revision b2df76ea8fec9e32f6f3718986dba0d95315b29c
1ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// Copyright (c) 2011 The Chromium Authors. All rights reserved.
2ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// Use of this source code is governed by a BSD-style license that can be
383a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius// found in the LICENSE file.
4ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
5ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#ifndef NET_URL_REQUEST_URL_REQUEST_JOB_FACTORY_H_
6ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define NET_URL_REQUEST_URL_REQUEST_JOB_FACTORY_H_
7ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
8ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include <string>
9ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
10ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "base/basictypes.h"
11ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "base/compiler_specific.h"
12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "base/threading/non_thread_safe.h"
13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "net/base/net_export.h"
14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass GURL;
16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
17ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querunamespace net {
18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass NetworkDelegate;
20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass URLRequest;
21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass URLRequestJob;
22ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
23ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass NET_EXPORT URLRequestJobFactory
24ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    : NON_EXPORTED_BASE(public base::NonThreadSafe) {
25ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru public:
26ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  // TODO(shalev): Move this to URLRequestJobFactoryImpl.
27ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  class NET_EXPORT ProtocolHandler {
28ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   public:
29ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual ~ProtocolHandler();
30ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
31ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual URLRequestJob* MaybeCreateJob(
32ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        URLRequest* request, NetworkDelegate* network_delegate) const = 0;
33ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    // Indicates if it should be safe to redirect to |location|. Should handle
35ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    // protocols handled by MaybeCreateJob().  Only called when registered with
36ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    // URLRequestJobFactoryImpl::SetProtocolHandler() not called when used with
37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    // ProtocolInterceptJobFactory.
38ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    // NOTE(pauljensen): Default implementation returns true.
39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual bool IsSafeRedirectTarget(const GURL& location) const;
40ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  };
41ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
42ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  URLRequestJobFactory();
43ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual ~URLRequestJobFactory();
44ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual URLRequestJob* MaybeCreateJobWithProtocolHandler(
46ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      const std::string& scheme,
47ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      URLRequest* request,
48ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      NetworkDelegate* network_delegate) const = 0;
49ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
50ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual bool IsHandledProtocol(const std::string& scheme) const = 0;
51ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
52ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual bool IsHandledURL(const GURL& url) const = 0;
53ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
54ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual bool IsSafeRedirectTarget(const GURL& location) const = 0;
55ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
56ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru private:
57ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  DISALLOW_COPY_AND_ASSIGN(URLRequestJobFactory);
58ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru};
59ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
60ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}  // namespace net
61ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
62ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif  // NET_URL_REQUEST_URL_REQUEST_JOB_FACTORY_H_
63ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru