OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #include "core/loader/SubresourceFilter.h" | 5 #include "core/loader/SubresourceFilter.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
10 #include "core/dom/TaskRunnerHelper.h" | 10 #include "core/dom/TaskRunnerHelper.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 bool SubresourceFilter::AllowWebSocketConnection(const KURL& url) { | 62 bool SubresourceFilter::AllowWebSocketConnection(const KURL& url) { |
63 WebDocumentSubresourceFilter::LoadPolicy load_policy = | 63 WebDocumentSubresourceFilter::LoadPolicy load_policy = |
64 subresource_filter_->GetLoadPolicyForWebSocketConnect(url); | 64 subresource_filter_->GetLoadPolicyForWebSocketConnect(url); |
65 | 65 |
66 // Post a task to notify this load to avoid unduly blocking the worker | 66 // Post a task to notify this load to avoid unduly blocking the worker |
67 // thread. Note that this unconditionally calls reportLoad unlike allowLoad, | 67 // thread. Note that this unconditionally calls reportLoad unlike allowLoad, |
68 // because there aren't developer-invisible connections (like speculative | 68 // because there aren't developer-invisible connections (like speculative |
69 // preloads) happening here. | 69 // preloads) happening here. |
70 RefPtr<WebTaskRunner> task_runner = TaskRunnerHelper::Get( | 70 RefPtr<WebTaskRunner> task_runner = TaskRunnerHelper::Get( |
71 TaskType::kNetworking, document_loader_->GetFrame()); | 71 TaskType::kNetworking, document_loader_->GetFrame()); |
72 DCHECK(task_runner->RunsTasksOnCurrentThread()); | 72 DCHECK(task_runner->RunsTasksInCurrentSequence()); |
73 task_runner->PostTask(BLINK_FROM_HERE, | 73 task_runner->PostTask(BLINK_FROM_HERE, |
74 WTF::Bind(&SubresourceFilter::ReportLoad, | 74 WTF::Bind(&SubresourceFilter::ReportLoad, |
75 WrapPersistent(this), url, load_policy)); | 75 WrapPersistent(this), url, load_policy)); |
76 return load_policy != WebDocumentSubresourceFilter::kDisallow; | 76 return load_policy != WebDocumentSubresourceFilter::kDisallow; |
77 } | 77 } |
78 | 78 |
79 void SubresourceFilter::ReportLoad( | 79 void SubresourceFilter::ReportLoad( |
80 const KURL& resource_url, | 80 const KURL& resource_url, |
81 WebDocumentSubresourceFilter::LoadPolicy load_policy) { | 81 WebDocumentSubresourceFilter::LoadPolicy load_policy) { |
82 Document* document = document_loader_->GetFrame() | 82 Document* document = document_loader_->GetFrame() |
(...skipping 17 matching lines...) Expand all Loading... |
100 } | 100 } |
101 // fall through | 101 // fall through |
102 case WebDocumentSubresourceFilter::kWouldDisallow: | 102 case WebDocumentSubresourceFilter::kWouldDisallow: |
103 document_loader_->DidObserveLoadingBehavior( | 103 document_loader_->DidObserveLoadingBehavior( |
104 kWebLoadingBehaviorSubresourceFilterMatch); | 104 kWebLoadingBehaviorSubresourceFilterMatch); |
105 break; | 105 break; |
106 } | 106 } |
107 } | 107 } |
108 | 108 |
109 } // namespace blink | 109 } // namespace blink |
OLD | NEW |