Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 WEBKIT_COMMON_RESOURCE_TYPE_H__ | 5 #ifndef CONTENT_PUBLIC_COMMON_RESOURCE_TYPE_H_ |
| 6 #define WEBKIT_COMMON_RESOURCE_TYPE_H__ | 6 #define CONTENT_PUBLIC_COMMON_RESOURCE_TYPE_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/macros.h" |
| 9 #include "content/common/content_export.h" | |
| 9 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 10 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 10 #include "webkit/common/webkit_common_export.h" | |
| 11 | 11 |
| 12 class ResourceType { | 12 namespace content { |
| 13 | |
| 14 class CONTENT_EXPORT ResourceType { | |
| 13 public: | 15 public: |
| 14 // Used in histograms, so please add new types at the end, and rename unused | 16 // Used in histograms, so please add new types at the end, and rename unused |
| 15 // entries to RESOURCETYPE_UNUSED_0, etc... | 17 // entries to RESOURCETYPE_UNUSED_0, etc... |
| 16 enum Type { | 18 enum Type { |
| 17 MAIN_FRAME = 0, // top level page | 19 MAIN_FRAME = 0, // top level page |
|
jam
2014/07/14 15:16:31
now that this is in content/public, it should conf
tfarina
2014/07/27 23:50:02
Hi John,
I will be addressing this here -> https:
| |
| 18 SUB_FRAME, // frame or iframe | 20 SUB_FRAME, // frame or iframe |
| 19 STYLESHEET, // a CSS stylesheet | 21 STYLESHEET, // a CSS stylesheet |
| 20 SCRIPT, // an external script | 22 SCRIPT, // an external script |
| 21 IMAGE, // an image (jpg/gif/png/etc) | 23 IMAGE, // an image (jpg/gif/png/etc) |
| 22 FONT_RESOURCE, // a font | 24 FONT_RESOURCE, // a font |
| 23 SUB_RESOURCE, // an "other" subresource. | 25 SUB_RESOURCE, // an "other" subresource. |
| 24 OBJECT, // an object (or embed) tag for a plugin, | 26 OBJECT, // an object (or embed) tag for a plugin, |
| 25 // or a resource that a plugin requested. | 27 // or a resource that a plugin requested. |
| 26 MEDIA, // a media resource. | 28 MEDIA, // a media resource. |
| 27 WORKER, // the main resource of a dedicated worker. | 29 WORKER, // the main resource of a dedicated worker. |
| 28 SHARED_WORKER, // the main resource of a shared worker. | 30 SHARED_WORKER, // the main resource of a shared worker. |
| 29 PREFETCH, // an explicitly requested prefetch | 31 PREFETCH, // an explicitly requested prefetch |
| 30 FAVICON, // a favicon | 32 FAVICON, // a favicon |
| 31 XHR, // a XMLHttpRequest | 33 XHR, // a XMLHttpRequest |
| 32 PING, // a ping request for <a ping> | 34 PING, // a ping request for <a ping> |
| 33 SERVICE_WORKER, // the main resource of a service worker. | 35 SERVICE_WORKER, // the main resource of a service worker. |
| 34 LAST_TYPE // Place holder so we don't need to change ValidType | 36 LAST_TYPE // Place holder so we don't need to change ValidType |
| 35 // everytime. | 37 // everytime. |
| 36 }; | 38 }; |
| 37 | 39 |
| 40 static Type FromTargetType(blink::WebURLRequest::TargetType type); | |
| 41 | |
| 38 static bool ValidType(int32 type) { | 42 static bool ValidType(int32 type) { |
| 39 return type >= MAIN_FRAME && type < LAST_TYPE; | 43 return type >= MAIN_FRAME && type < LAST_TYPE; |
| 40 } | 44 } |
| 41 | 45 |
| 42 static Type FromInt(int32 type) { | 46 static Type FromInt(int32 type) { |
| 43 return static_cast<Type>(type); | 47 return static_cast<Type>(type); |
| 44 } | 48 } |
| 45 | 49 |
| 46 WEBKIT_COMMON_EXPORT static Type FromTargetType( | |
| 47 blink::WebURLRequest::TargetType type); | |
| 48 | |
| 49 static bool IsFrame(ResourceType::Type type) { | 50 static bool IsFrame(ResourceType::Type type) { |
| 50 return type == MAIN_FRAME || type == SUB_FRAME; | 51 return type == MAIN_FRAME || type == SUB_FRAME; |
| 51 } | 52 } |
| 52 | 53 |
| 53 static bool IsSharedWorker(ResourceType::Type type) { | 54 static bool IsSharedWorker(ResourceType::Type type) { |
| 54 return type == SHARED_WORKER; | 55 return type == SHARED_WORKER; |
| 55 } | 56 } |
| 56 | 57 |
| 57 static bool IsServiceWorker(ResourceType::Type type) { | 58 static bool IsServiceWorker(ResourceType::Type type) { |
| 58 return type == SERVICE_WORKER; | 59 return type == SERVICE_WORKER; |
| 59 } | 60 } |
| 60 | 61 |
| 61 static bool IsSubresource(ResourceType::Type type) { | 62 static bool IsSubresource(ResourceType::Type type) { |
| 62 return type == STYLESHEET || | 63 return type == STYLESHEET || |
| 63 type == SCRIPT || | 64 type == SCRIPT || |
| 64 type == IMAGE || | 65 type == IMAGE || |
| 65 type == FONT_RESOURCE || | 66 type == FONT_RESOURCE || |
| 66 type == SUB_RESOURCE || | 67 type == SUB_RESOURCE || |
| 67 type == WORKER || | 68 type == WORKER || |
| 68 type == XHR; | 69 type == XHR; |
| 69 } | 70 } |
| 70 | 71 |
| 71 private: | 72 private: |
| 72 // Don't instantiate this class. | 73 DISALLOW_COPY_AND_ASSIGN(ResourceType); |
| 73 ResourceType(); | |
| 74 ~ResourceType(); | |
| 75 }; | 74 }; |
| 76 #endif // WEBKIT_COMMON_RESOURCE_TYPE_H__ | 75 |
| 76 } // namespace content | |
| 77 | |
| 78 #endif // CONTENT_PUBLIC_COMMON_RESOURCE_TYPE_H_ | |
| OLD | NEW |