OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/shared_worker/shared_worker_instance.h" | 5 #include "content/browser/shared_worker/shared_worker_instance.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 namespace content { | 9 namespace content { |
10 | 10 |
11 SharedWorkerInstance::SharedWorkerInstance( | 11 SharedWorkerInstance::SharedWorkerInstance( |
12 const GURL& url, | 12 const GURL& url, |
13 const base::string16& name, | 13 const base::string16& name, |
14 const base::string16& content_security_policy, | 14 const base::string16& content_security_policy, |
15 blink::WebContentSecurityPolicyType security_policy_type, | 15 blink::WebContentSecurityPolicyType security_policy_type, |
16 ResourceContext* resource_context, | 16 ResourceContext* resource_context, |
17 const WorkerStoragePartition& partition) | 17 const WorkerStoragePartitionId& partition_id) |
18 : url_(url), | 18 : url_(url), |
19 name_(name), | 19 name_(name), |
20 content_security_policy_(content_security_policy), | 20 content_security_policy_(content_security_policy), |
21 security_policy_type_(security_policy_type), | 21 security_policy_type_(security_policy_type), |
22 resource_context_(resource_context), | 22 resource_context_(resource_context), |
23 partition_(partition) { | 23 partition_id_(partition_id) { |
24 DCHECK(resource_context_); | 24 DCHECK(resource_context_); |
25 } | 25 } |
26 | 26 |
27 SharedWorkerInstance::SharedWorkerInstance(const SharedWorkerInstance& other) | 27 SharedWorkerInstance::SharedWorkerInstance(const SharedWorkerInstance& other) |
28 : url_(other.url_), | 28 : url_(other.url_), |
29 name_(other.name_), | 29 name_(other.name_), |
30 content_security_policy_(other.content_security_policy_), | 30 content_security_policy_(other.content_security_policy_), |
31 security_policy_type_(other.security_policy_type_), | 31 security_policy_type_(other.security_policy_type_), |
32 resource_context_(other.resource_context_), | 32 resource_context_(other.resource_context_), |
33 partition_(other.partition_) {} | 33 partition_id_(other.partition_id_) { |
| 34 } |
34 | 35 |
35 SharedWorkerInstance::~SharedWorkerInstance() {} | 36 SharedWorkerInstance::~SharedWorkerInstance() {} |
36 | 37 |
37 bool SharedWorkerInstance::Matches(const GURL& match_url, | 38 bool SharedWorkerInstance::Matches(const GURL& match_url, |
38 const base::string16& match_name, | 39 const base::string16& match_name, |
39 const WorkerStoragePartition& partition, | 40 const WorkerStoragePartitionId& partition_id, |
40 ResourceContext* resource_context) const { | 41 ResourceContext* resource_context) const { |
41 // ResourceContext equivalence is being used as a proxy to ensure we only | 42 // ResourceContext equivalence is being used as a proxy to ensure we only |
42 // matched shared workers within the same BrowserContext. | 43 // matched shared workers within the same BrowserContext. |
43 if (resource_context_ != resource_context) | 44 if (resource_context_ != resource_context) |
44 return false; | 45 return false; |
45 | 46 |
46 // We must be in the same storage partition otherwise sharing will violate | 47 // We must be in the same storage partition otherwise sharing will violate |
47 // isolation. | 48 // isolation. |
48 if (!partition_.Equals(partition)) | 49 if (!partition_id_.Equals(partition_id)) |
49 return false; | 50 return false; |
50 | 51 |
51 if (url_.GetOrigin() != match_url.GetOrigin()) | 52 if (url_.GetOrigin() != match_url.GetOrigin()) |
52 return false; | 53 return false; |
53 | 54 |
54 if (name_.empty() && match_name.empty()) | 55 if (name_.empty() && match_name.empty()) |
55 return url_ == match_url; | 56 return url_ == match_url; |
56 | 57 |
57 return name_ == match_name; | 58 return name_ == match_name; |
58 } | 59 } |
59 | 60 |
60 bool SharedWorkerInstance::Matches(const SharedWorkerInstance& other) const { | 61 bool SharedWorkerInstance::Matches(const SharedWorkerInstance& other) const { |
61 return Matches( | 62 return Matches(other.url(), |
62 other.url(), other.name(), other.partition(), other.resource_context()); | 63 other.name(), |
| 64 other.partition_id(), |
| 65 other.resource_context()); |
63 } | 66 } |
64 | 67 |
65 } // namespace content | 68 } // namespace content |
OLD | NEW |