OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading | 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading |
6 | 6 |
7 #include "content/child/resource_dispatcher.h" | 7 #include "content/child/resource_dispatcher.h" |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
| 11 #include "base/atomic_sequence_num.h" |
11 #include "base/bind.h" | 12 #include "base/bind.h" |
12 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
13 #include "base/debug/alias.h" | 14 #include "base/debug/alias.h" |
14 #include "base/debug/dump_without_crashing.h" | 15 #include "base/debug/dump_without_crashing.h" |
15 #include "base/debug/stack_trace.h" | 16 #include "base/debug/stack_trace.h" |
16 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
17 #include "base/memory/ptr_util.h" | 18 #include "base/memory/ptr_util.h" |
18 #include "base/memory/shared_memory.h" | 19 #include "base/memory/shared_memory.h" |
19 #include "base/message_loop/message_loop.h" | 20 #include "base/message_loop/message_loop.h" |
20 #include "base/metrics/histogram_macros.h" | 21 #include "base/metrics/histogram_macros.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 base::debug::Alias(&last_err); | 61 base::debug::Alias(&last_err); |
61 #endif | 62 #endif |
62 CHECK(false); | 63 CHECK(false); |
63 } | 64 } |
64 | 65 |
65 // Each resource request is assigned an ID scoped to this process. | 66 // Each resource request is assigned an ID scoped to this process. |
66 int MakeRequestID() { | 67 int MakeRequestID() { |
67 // NOTE: The resource_dispatcher_host also needs probably unique | 68 // NOTE: The resource_dispatcher_host also needs probably unique |
68 // request_ids, so they count down from -2 (-1 is a special we're | 69 // request_ids, so they count down from -2 (-1 is a special we're |
69 // screwed value), while the renderer process counts up. | 70 // screwed value), while the renderer process counts up. |
70 static int next_request_id = 0; | 71 static base::StaticAtomicSequenceNumber sequence; |
71 return next_request_id++; | 72 return sequence.GetNext(); // We start at zero. |
72 } | 73 } |
73 | 74 |
74 void CheckSchemeForReferrerPolicy(const ResourceRequest& request) { | 75 void CheckSchemeForReferrerPolicy(const ResourceRequest& request) { |
75 if ((request.referrer_policy == blink::kWebReferrerPolicyDefault || | 76 if ((request.referrer_policy == blink::kWebReferrerPolicyDefault || |
76 request.referrer_policy == | 77 request.referrer_policy == |
77 blink::kWebReferrerPolicyNoReferrerWhenDowngrade) && | 78 blink::kWebReferrerPolicyNoReferrerWhenDowngrade) && |
78 request.referrer.SchemeIsCryptographic() && | 79 request.referrer.SchemeIsCryptographic() && |
79 !request.url.SchemeIsCryptographic()) { | 80 !request.url.SchemeIsCryptographic()) { |
80 LOG(FATAL) << "Trying to send secure referrer for insecure request " | 81 LOG(FATAL) << "Trying to send secure referrer for insecure request " |
81 << "without an appropriate referrer policy.\n" | 82 << "without an appropriate referrer policy.\n" |
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 delete message; | 838 delete message; |
838 } | 839 } |
839 } | 840 } |
840 | 841 |
841 void ResourceDispatcher::SetResourceSchedulingFilter( | 842 void ResourceDispatcher::SetResourceSchedulingFilter( |
842 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { | 843 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { |
843 resource_scheduling_filter_ = resource_scheduling_filter; | 844 resource_scheduling_filter_ = resource_scheduling_filter; |
844 } | 845 } |
845 | 846 |
846 } // namespace content | 847 } // namespace content |
OLD | NEW |