| 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 #ifndef CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_INSTANCE_H_ | 5 #ifndef CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_INSTANCE_H_ |
| 6 #define CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_INSTANCE_H_ | 6 #define CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_INSTANCE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "content/browser/worker_host/worker_storage_partition.h" | 11 #include "content/browser/worker_host/worker_storage_partition.h" |
| 12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
| 13 #include "third_party/WebKit/public/web/WebContentSecurityPolicy.h" | 13 #include "third_party/WebKit/public/web/WebContentSecurityPolicy.h" |
| 14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 class ResourceContext; | 17 class ResourceContext; |
| 18 | 18 |
| 19 // SharedWorkerInstance is copyable value-type data type. It could be passed to | 19 // SharedWorkerInstance is copyable value-type data type. It could be passed to |
| 20 // the UI thread and be used for comparison in SharedWorkerDevToolsManager. | 20 // the UI thread and be used for comparison in SharedWorkerDevToolsManager. |
| 21 class CONTENT_EXPORT SharedWorkerInstance { | 21 class CONTENT_EXPORT SharedWorkerInstance { |
| 22 public: | 22 public: |
| 23 SharedWorkerInstance(const GURL& url, | 23 SharedWorkerInstance(const GURL& url, |
| 24 const base::string16& name, | 24 const base::string16& name, |
| 25 const base::string16& content_security_policy, | 25 const base::string16& content_security_policy, |
| 26 blink::WebContentSecurityPolicyType security_policy_type, | 26 blink::WebContentSecurityPolicyType security_policy_type, |
| 27 ResourceContext* resource_context, | 27 ResourceContext* resource_context, |
| 28 const WorkerStoragePartition& partition); | 28 const WorkerStoragePartitionId& partition_id); |
| 29 SharedWorkerInstance(const SharedWorkerInstance& other); | 29 SharedWorkerInstance(const SharedWorkerInstance& other); |
| 30 ~SharedWorkerInstance(); | 30 ~SharedWorkerInstance(); |
| 31 | 31 |
| 32 // Checks if this SharedWorkerInstance matches the passed url/name params | 32 // Checks if this SharedWorkerInstance matches the passed url/name params |
| 33 // based on the algorithm in the WebWorkers spec - an instance matches if the | 33 // based on the algorithm in the WebWorkers spec - an instance matches if the |
| 34 // origins of the URLs match, and: | 34 // origins of the URLs match, and: |
| 35 // a) the names are non-empty and equal. | 35 // a) the names are non-empty and equal. |
| 36 // -or- | 36 // -or- |
| 37 // b) the names are both empty, and the urls are equal. | 37 // b) the names are both empty, and the urls are equal. |
| 38 bool Matches( | 38 bool Matches(const GURL& url, |
| 39 const GURL& url, | 39 const base::string16& name, |
| 40 const base::string16& name, | 40 const WorkerStoragePartitionId& partition, |
| 41 const WorkerStoragePartition& partition, | 41 ResourceContext* resource_context) const; |
| 42 ResourceContext* resource_context) const; | |
| 43 bool Matches(const SharedWorkerInstance& other) const; | 42 bool Matches(const SharedWorkerInstance& other) const; |
| 44 | 43 |
| 45 // Accessors. | 44 // Accessors. |
| 46 const GURL& url() const { return url_; } | 45 const GURL& url() const { return url_; } |
| 47 const base::string16 name() const { return name_; } | 46 const base::string16 name() const { return name_; } |
| 48 const base::string16 content_security_policy() const { | 47 const base::string16 content_security_policy() const { |
| 49 return content_security_policy_; | 48 return content_security_policy_; |
| 50 } | 49 } |
| 51 blink::WebContentSecurityPolicyType security_policy_type() const { | 50 blink::WebContentSecurityPolicyType security_policy_type() const { |
| 52 return security_policy_type_; | 51 return security_policy_type_; |
| 53 } | 52 } |
| 54 ResourceContext* resource_context() const { | 53 ResourceContext* resource_context() const { |
| 55 return resource_context_; | 54 return resource_context_; |
| 56 } | 55 } |
| 57 const WorkerStoragePartition& partition() const { | 56 const WorkerStoragePartitionId& partition_id() const { return partition_id_; } |
| 58 return partition_; | |
| 59 } | |
| 60 | 57 |
| 61 private: | 58 private: |
| 62 const GURL url_; | 59 const GURL url_; |
| 63 const base::string16 name_; | 60 const base::string16 name_; |
| 64 const base::string16 content_security_policy_; | 61 const base::string16 content_security_policy_; |
| 65 const blink::WebContentSecurityPolicyType security_policy_type_; | 62 const blink::WebContentSecurityPolicyType security_policy_type_; |
| 66 ResourceContext* const resource_context_; | 63 ResourceContext* const resource_context_; |
| 67 const WorkerStoragePartition partition_; | 64 const WorkerStoragePartitionId partition_id_; |
| 68 }; | 65 }; |
| 69 | 66 |
| 70 } // namespace content | 67 } // namespace content |
| 71 | 68 |
| 72 | 69 |
| 73 #endif // CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_INSTANCE_H_ | 70 #endif // CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_INSTANCE_H_ |
| OLD | NEW |