Chromium Code Reviews| 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_SERVICE_WORKER_SERVICE_WORKER_UTILS_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_UTILS_H_ |
| 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_UTILS_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_UTILS_H_ |
| 7 | 7 |
| 8 #include <vector> | |
|
jsbell
2014/06/03 18:48:30
Not needed any more?
nhiroki
2014/06/05 11:00:35
Done.
| |
| 9 | |
| 8 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
| 9 #include "content/common/service_worker/service_worker_status_code.h" | 11 #include "content/common/service_worker/service_worker_status_code.h" |
| 10 #include "webkit/common/resource_type.h" | 12 #include "webkit/common/resource_type.h" |
| 11 | 13 |
| 14 class GURL; | |
| 15 | |
| 12 namespace content { | 16 namespace content { |
| 13 | 17 |
| 14 class ServiceWorkerUtils { | 18 class ServiceWorkerUtils { |
| 15 public: | 19 public: |
| 16 static bool IsMainResourceType(ResourceType::Type type) { | 20 static bool IsMainResourceType(ResourceType::Type type) { |
| 17 return ResourceType::IsFrame(type) || | 21 return ResourceType::IsFrame(type) || |
| 18 ResourceType::IsSharedWorker(type); | 22 ResourceType::IsSharedWorker(type); |
| 19 } | 23 } |
| 20 | 24 |
| 21 static bool IsServiceWorkerResourceType(ResourceType::Type type) { | 25 static bool IsServiceWorkerResourceType(ResourceType::Type type) { |
| 22 return ResourceType::IsServiceWorker(type); | 26 return ResourceType::IsServiceWorker(type); |
| 23 } | 27 } |
| 24 | 28 |
| 25 // Returns true if the feature is enabled (or not disabled) by command-line | 29 // Returns true if the feature is enabled (or not disabled) by command-line |
| 26 // flag. | 30 // flag. |
| 27 static bool IsFeatureEnabled(); | 31 static bool IsFeatureEnabled(); |
| 28 | 32 |
| 29 // A helper for creating a do-nothing status callback. | 33 // A helper for creating a do-nothing status callback. |
| 30 static void NoOpStatusCallback(ServiceWorkerStatusCode status) {} | 34 static void NoOpStatusCallback(ServiceWorkerStatusCode status) {} |
| 31 | 35 |
| 32 // Returns true if |scope| matches |url|. | 36 // Returns true if |scope| matches |url|. |
| 33 CONTENT_EXPORT static bool ScopeMatches(const GURL& scope, const GURL& url); | 37 CONTENT_EXPORT static bool ScopeMatches(const GURL& scope, const GURL& url); |
| 34 }; | 38 }; |
| 35 | 39 |
| 40 class CONTENT_EXPORT LongestScopeMatcher { | |
| 41 public: | |
| 42 explicit LongestScopeMatcher(const GURL& url) : url_(url) {} | |
| 43 virtual ~LongestScopeMatcher() {} | |
| 44 | |
| 45 // Returns true if |scope| matches |url_| longer than |match_|. | |
| 46 bool MatchLongest(const GURL& scope); | |
| 47 | |
| 48 private: | |
| 49 const GURL url_; | |
| 50 GURL match_; | |
| 51 | |
| 52 DISALLOW_COPY_AND_ASSIGN(LongestScopeMatcher); | |
| 53 }; | |
| 54 | |
| 36 } // namespace content | 55 } // namespace content |
| 37 | 56 |
| 38 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_UTILS_H_ | 57 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_UTILS_H_ |
| OLD | NEW |