OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_GLUE_RESOURCE_TYPE_H__ | 5 #ifndef WEBKIT_GLUE_RESOURCE_TYPE_H__ |
6 #define WEBKIT_GLUE_RESOURCE_TYPE_H__ | 6 #define WEBKIT_GLUE_RESOURCE_TYPE_H__ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" | 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" |
10 | 10 |
11 class ResourceType { | 11 class ResourceType { |
12 public: | 12 public: |
13 enum Type { | 13 enum Type { |
14 MAIN_FRAME = 0, // top level page | 14 MAIN_FRAME = 0, // top level page |
15 SUB_FRAME, // frame or iframe | 15 SUB_FRAME, // frame or iframe |
16 STYLESHEET, // a CSS stylesheet | 16 STYLESHEET, // a CSS stylesheet |
17 SCRIPT, // an external script | 17 SCRIPT, // an external script |
18 IMAGE, // an image (jpg/gif/png/etc) | 18 IMAGE, // an image (jpg/gif/png/etc) |
19 FONT_RESOURCE, // a font | 19 FONT_RESOURCE, // a font |
20 SUB_RESOURCE, // an "other" subresource. | 20 SUB_RESOURCE, // an "other" subresource. |
21 OBJECT, // an object (or embed) tag for a plugin, | 21 OBJECT, // an object (or embed) tag for a plugin, |
22 // or a resource that a plugin requested. | 22 // or a resource that a plugin requested. |
23 MEDIA, // a media resource. | 23 MEDIA, // a media resource. |
24 WORKER, // the main resource of a dedicated worker. | 24 WORKER, // the main resource of a dedicated worker. |
25 SHARED_WORKER, // the main resource of a shared worker. | 25 SHARED_WORKER, // the main resource of a shared worker. |
26 PREFETCH, // an explicitly requested prefetch | 26 PREFETCH, // an explicitly requested prefetch |
27 PRERENDER, // an explicitly requested prerender | 27 PRERENDER, // an explicitly requested prerender |
28 FAVICON, // a favicon | 28 FAVICON, // a favicon |
| 29 XHR, // a XMLHttpRequest |
29 LAST_TYPE // Place holder so we don't need to change ValidType | 30 LAST_TYPE // Place holder so we don't need to change ValidType |
30 // everytime. | 31 // everytime. |
31 }; | 32 }; |
32 | 33 |
33 static bool ValidType(int32 type) { | 34 static bool ValidType(int32 type) { |
34 return type >= MAIN_FRAME && type < LAST_TYPE; | 35 return type >= MAIN_FRAME && type < LAST_TYPE; |
35 } | 36 } |
36 | 37 |
37 static Type FromInt(int32 type) { | 38 static Type FromInt(int32 type) { |
38 return static_cast<Type>(type); | 39 return static_cast<Type>(type); |
39 } | 40 } |
40 | 41 |
41 static Type FromTargetType(WebKit::WebURLRequest::TargetType type); | 42 static Type FromTargetType(WebKit::WebURLRequest::TargetType type); |
42 | 43 |
43 static bool IsFrame(ResourceType::Type type) { | 44 static bool IsFrame(ResourceType::Type type) { |
44 return type == MAIN_FRAME || type == SUB_FRAME; | 45 return type == MAIN_FRAME || type == SUB_FRAME; |
45 } | 46 } |
46 | 47 |
47 static bool IsSharedWorker(ResourceType::Type type) { | 48 static bool IsSharedWorker(ResourceType::Type type) { |
48 return type == SHARED_WORKER; | 49 return type == SHARED_WORKER; |
49 } | 50 } |
50 | 51 |
51 static bool IsSubresource(ResourceType::Type type) { | 52 static bool IsSubresource(ResourceType::Type type) { |
52 return type == STYLESHEET || | 53 return type == STYLESHEET || |
53 type == SCRIPT || | 54 type == SCRIPT || |
54 type == IMAGE || | 55 type == IMAGE || |
55 type == FONT_RESOURCE || | 56 type == FONT_RESOURCE || |
56 type == SUB_RESOURCE || | 57 type == SUB_RESOURCE || |
57 type == WORKER; | 58 type == WORKER || |
| 59 type == XHR; |
58 } | 60 } |
59 | 61 |
60 private: | 62 private: |
61 // Don't instantiate this class. | 63 // Don't instantiate this class. |
62 ResourceType(); | 64 ResourceType(); |
63 ~ResourceType(); | 65 ~ResourceType(); |
64 }; | 66 }; |
65 #endif // WEBKIT_GLUE_RESOURCE_TYPE_H__ | 67 #endif // WEBKIT_GLUE_RESOURCE_TYPE_H__ |
OLD | NEW |