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