blob: ce727c5579afbceb5256a5fb2994fe0159854ab5 (
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
// Copyright (c) 2017 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 CONTENT_BROWSER_APPCACHE_APPCACHE_REQUEST_H_
#define CONTENT_BROWSER_APPCACHE_APPCACHE_REQUEST_H_
#include "base/logging.h"
#include "base/strings/string16.h"
#include "base/threading/non_thread_safe.h"
#include "content/common/content_export.h"
#include "url/gurl.h"
namespace net {
class URLRequest;
}
namespace content {
struct ResourceRequest;
// Interface for an AppCache request. Subclasses implement this interface to
// wrap custom request objects like URLRequest, etc to ensure that these
// dependencies stay out of the AppCache code.
class CONTENT_EXPORT AppCacheRequest
: NON_EXPORTED_BASE(public base::NonThreadSafe) {
public:
virtual ~AppCacheRequest() {}
// The URL for this request.
virtual const GURL& GetURL() const = 0;
// The method for this request
virtual const std::string& GetMethod() const = 0;
// Used for cookie policy.
virtual const GURL& GetFirstPartyForCookies() const = 0;
// The referrer for this request.
virtual const GURL GetReferrer() const = 0;
// Returns true if the request was successful.
virtual bool IsSuccess() const = 0;
// Returns true if the request was cancelled.
virtual bool IsCancelled() const = 0;
// Returns true if the request had an error.
virtual bool IsError() const = 0;
// Returns the HTTP response code.
virtual int GetResponseCode() const = 0;
// Get response header(s) by name. Returns an empty string if the header
// wasn't found,
virtual std::string GetResponseHeaderByName(
const std::string& name) const = 0;
// Returns true if the scheme and method are supported for AppCache.
static bool IsSchemeAndMethodSupportedForAppCache(
const AppCacheRequest* request);
protected:
friend class AppCacheRequestHandler;
// Enables the AppCacheJob to call GetURLRequest() and GetResourceRequest().
friend class AppCacheJob;
AppCacheRequest() {}
// Getters for the request types we currently support.
virtual net::URLRequest* GetURLRequest();
// Returns the underlying ResourceRequest. Please note that only one of
// GetURLRequest() and GetResourceRequest() should return valid results.
virtual ResourceRequest* GetResourceRequest();
DISALLOW_COPY_AND_ASSIGN(AppCacheRequest);
};
} // namespace content
#endif // CONTENT_BROWSER_APPCACHE_APPCACHE_REQUEST_H_
|