forked from Pissandshittium/pissandshittium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce/Remove URLRequest dependencies from AppCacheRequestHandler
The AppCacheRequestHandler class provides functionality for serving network requests from the AppCache if applicable. This class is instantiated by the AppCacheInterceptor when a network request is initiated. Its lifetime depends on the associated URLRequest. The plan is to reuse this class in the network service world where we won't be intercepting network requests in the browser process. This effectively means that there won't be any URLRequest as well To achieve this the proposal is to provide an abstraction for a request called AppCachRequest. This class will have two subclasses at the moment. AppCacheURLRequest and AppCacheURLLoaderRequest. The AppCacheURLRequest class will be used by the current network implementation which relies on intercepting n/w requests. The AppCacheURLLoaderRequest class will be used by the network service mojo implementation. Next step is to provide an abstraction for the AppCacheURLRequestJob class. BUG=715632 TBR=jam Review-Url: https://codereview.chromium.org/2848493007 Cr-Commit-Position: refs/heads/master@{#469254}
- Loading branch information
ananta
authored and
Commit bot
committed
May 4, 2017
1 parent
2d7e67c
commit 4e8a529
Showing
15 changed files
with
523 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// 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. | ||
|
||
#include "content/browser/appcache/appcache_request.h" | ||
#include "content/common/appcache_interfaces.h" | ||
#include "net/url_request/url_request.h" | ||
|
||
namespace content { | ||
|
||
// static | ||
bool AppCacheRequest::IsSchemeAndMethodSupportedForAppCache( | ||
const AppCacheRequest* request) { | ||
return IsSchemeSupportedForAppCache(request->GetURL()) && | ||
IsMethodSupportedForAppCache(request->GetMethod()); | ||
} | ||
|
||
net::URLRequest* AppCacheRequest::GetURLRequest() { | ||
return nullptr; | ||
} | ||
|
||
ResourceRequest* AppCacheRequest::GetResourceRequest() { | ||
return nullptr; | ||
} | ||
|
||
} // namespace content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// 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; | ||
|
||
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_ |
Oops, something went wrong.