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_GLUE_RESOURCE_TYPE_H__ | 5 #ifndef WEBKIT_COMMON_RESOURCE_TYPE_H__ |
6 #define WEBKIT_GLUE_RESOURCE_TYPE_H__ | 6 #define WEBKIT_COMMON_RESOURCE_TYPE_H__ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 9 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
10 #include "webkit/glue/webkit_glue_export.h" | 10 #include "webkit/common/webkit_common_export.h" |
11 | 11 |
12 class ResourceType { | 12 class ResourceType { |
13 public: | 13 public: |
14 // Used in histograms, so please add new types at the end, and rename unused | 14 // Used in histograms, so please add new types at the end, and rename unused |
15 // entries to RESOURCETYPE_UNUSED_0, etc... | 15 // entries to RESOURCETYPE_UNUSED_0, etc... |
16 enum Type { | 16 enum Type { |
17 MAIN_FRAME = 0, // top level page | 17 MAIN_FRAME = 0, // top level page |
18 SUB_FRAME, // frame or iframe | 18 SUB_FRAME, // frame or iframe |
19 STYLESHEET, // a CSS stylesheet | 19 STYLESHEET, // a CSS stylesheet |
20 SCRIPT, // an external script | 20 SCRIPT, // an external script |
(...skipping 13 matching lines...) Expand all Loading... |
34 }; | 34 }; |
35 | 35 |
36 static bool ValidType(int32 type) { | 36 static bool ValidType(int32 type) { |
37 return type >= MAIN_FRAME && type < LAST_TYPE; | 37 return type >= MAIN_FRAME && type < LAST_TYPE; |
38 } | 38 } |
39 | 39 |
40 static Type FromInt(int32 type) { | 40 static Type FromInt(int32 type) { |
41 return static_cast<Type>(type); | 41 return static_cast<Type>(type); |
42 } | 42 } |
43 | 43 |
44 WEBKIT_GLUE_EXPORT static Type FromTargetType( | 44 WEBKIT_COMMON_EXPORT static Type FromTargetType( |
45 WebKit::WebURLRequest::TargetType type); | 45 WebKit::WebURLRequest::TargetType type); |
46 | 46 |
47 static bool IsFrame(ResourceType::Type type) { | 47 static bool IsFrame(ResourceType::Type type) { |
48 return type == MAIN_FRAME || type == SUB_FRAME; | 48 return type == MAIN_FRAME || type == SUB_FRAME; |
49 } | 49 } |
50 | 50 |
51 static bool IsSharedWorker(ResourceType::Type type) { | 51 static bool IsSharedWorker(ResourceType::Type type) { |
52 return type == SHARED_WORKER; | 52 return type == SHARED_WORKER; |
53 } | 53 } |
54 | 54 |
55 static bool IsSubresource(ResourceType::Type type) { | 55 static bool IsSubresource(ResourceType::Type type) { |
56 return type == STYLESHEET || | 56 return type == STYLESHEET || |
57 type == SCRIPT || | 57 type == SCRIPT || |
58 type == IMAGE || | 58 type == IMAGE || |
59 type == FONT_RESOURCE || | 59 type == FONT_RESOURCE || |
60 type == SUB_RESOURCE || | 60 type == SUB_RESOURCE || |
61 type == WORKER || | 61 type == WORKER || |
62 type == XHR; | 62 type == XHR; |
63 } | 63 } |
64 | 64 |
65 private: | 65 private: |
66 // Don't instantiate this class. | 66 // Don't instantiate this class. |
67 ResourceType(); | 67 ResourceType(); |
68 ~ResourceType(); | 68 ~ResourceType(); |
69 }; | 69 }; |
70 #endif // WEBKIT_GLUE_RESOURCE_TYPE_H__ | 70 #endif // WEBKIT_COMMON_RESOURCE_TYPE_H__ |
OLD | NEW |