Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / public / common / resource_response.h
blob2c64d6195c3e0380853fceb7e6bd1c8f5d9aec7d
1 // Copyright (c) 2012 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.
5 // See http://dev.chromium.org/developers/design-documents/multi-process-resource-loading
7 #ifndef CONTENT_PUBLIC_COMMON_RESOURCE_RESPONSE_H_
8 #define CONTENT_PUBLIC_COMMON_RESOURCE_RESPONSE_H_
10 #include <string>
12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h"
14 #include "content/common/content_export.h"
15 #include "content/public/common/resource_response_info.h"
16 #include "net/url_request/url_request_status.h"
17 #include "url/gurl.h"
19 namespace content {
21 // Parameters for a resource response header.
22 struct ResourceResponseHead : ResourceResponseInfo {
23 // TimeTicks::Now() when the browser received the request from the renderer.
24 base::TimeTicks request_start;
25 // TimeTicks::Now() when the browser sent the response to the renderer.
26 base::TimeTicks response_start;
29 // Parameters for a synchronous resource response.
30 struct SyncLoadResult : ResourceResponseHead {
31 // The response error_code.
32 int error_code;
33 // The final URL after any redirects.
34 GURL final_url;
36 // The response data.
37 std::string data;
40 // Simple wrapper that refcounts ResourceResponseHead.
41 // Inherited, rather than typedef'd, to allow forward declarations.
42 struct CONTENT_EXPORT ResourceResponse
43 : public base::RefCountedThreadSafe<ResourceResponse> {
44 public:
45 ResourceResponseHead head;
47 // Performs a deep copy of the ResourceResponse and all fields in it, safe to
48 // pass across threads.
50 // TODO(davidben): This structure should be passed along in a scoped_ptr. It's
51 // currently reference-counted to avoid copies, but may be
52 // modified. https://crbug.com/416050
53 scoped_refptr<ResourceResponse> DeepCopy() const;
55 private:
56 friend class base::RefCountedThreadSafe<ResourceResponse>;
57 ~ResourceResponse() {}
60 } // namespace content
62 #endif // CONTENT_PUBLIC_COMMON_RESOURCE_RESPONSE_H_