Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1260)

Side by Side Diff: webkit/glue/resource_type.h

Issue 7461106: Inform disk cache of WebKit memory cache hits. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove rank from test Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/logging.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h"
9 11
10 class ResourceType { 12 class ResourceType {
11 public: 13 public:
12 enum Type { 14 enum Type {
13 MAIN_FRAME = 0, // top level page 15 MAIN_FRAME = 0, // top level page
14 SUB_FRAME, // frame or iframe 16 SUB_FRAME, // frame or iframe
15 STYLESHEET, // a CSS stylesheet 17 STYLESHEET, // a CSS stylesheet
16 SCRIPT, // an external script 18 SCRIPT, // an external script
17 IMAGE, // an image (jpg/gif/png/etc) 19 IMAGE, // an image (jpg/gif/png/etc)
18 FONT_RESOURCE, // a font 20 FONT_RESOURCE, // a font
(...skipping 11 matching lines...) Expand all
30 }; 32 };
31 33
32 static bool ValidType(int32 type) { 34 static bool ValidType(int32 type) {
33 return type >= MAIN_FRAME && type < LAST_TYPE; 35 return type >= MAIN_FRAME && type < LAST_TYPE;
34 } 36 }
35 37
36 static Type FromInt(int32 type) { 38 static Type FromInt(int32 type) {
37 return static_cast<Type>(type); 39 return static_cast<Type>(type);
38 } 40 }
39 41
42 static Type FromTargetType(WebKit::WebURLRequest::TargetType type) {
darin (slow to review) 2011/07/30 05:09:32 this is sizeable enough that it should not be impl
43 switch (type) {
44 case WebKit::WebURLRequest::TargetIsMainFrame:
45 return ResourceType::MAIN_FRAME;
46 case WebKit::WebURLRequest::TargetIsSubframe:
47 return ResourceType::SUB_FRAME;
48 case WebKit::WebURLRequest::TargetIsSubresource:
49 return ResourceType::SUB_RESOURCE;
50 case WebKit::WebURLRequest::TargetIsStyleSheet:
51 return ResourceType::STYLESHEET;
52 case WebKit::WebURLRequest::TargetIsScript:
53 return ResourceType::SCRIPT;
54 case WebKit::WebURLRequest::TargetIsFontResource:
55 return ResourceType::FONT_RESOURCE;
56 case WebKit::WebURLRequest::TargetIsImage:
57 return ResourceType::IMAGE;
58 case WebKit::WebURLRequest::TargetIsObject:
59 return ResourceType::OBJECT;
60 case WebKit::WebURLRequest::TargetIsMedia:
61 return ResourceType::MEDIA;
62 case WebKit::WebURLRequest::TargetIsWorker:
63 return ResourceType::WORKER;
64 case WebKit::WebURLRequest::TargetIsSharedWorker:
65 return ResourceType::SHARED_WORKER;
66 case WebKit::WebURLRequest::TargetIsPrefetch:
67 return ResourceType::PREFETCH;
68 case WebKit::WebURLRequest::TargetIsPrerender:
69 return ResourceType::PRERENDER;
70 case WebKit::WebURLRequest::TargetIsFavicon:
71 return ResourceType::FAVICON;
72 default:
73 NOTREACHED();
74 return ResourceType::SUB_RESOURCE;
75 }
76 }
77
40 static bool IsFrame(ResourceType::Type type) { 78 static bool IsFrame(ResourceType::Type type) {
41 return type == MAIN_FRAME || type == SUB_FRAME; 79 return type == MAIN_FRAME || type == SUB_FRAME;
42 } 80 }
43 81
44 static bool IsSharedWorker(ResourceType::Type type) { 82 static bool IsSharedWorker(ResourceType::Type type) {
45 return type == SHARED_WORKER; 83 return type == SHARED_WORKER;
46 } 84 }
47 85
48 static bool IsSubresource(ResourceType::Type type) { 86 static bool IsSubresource(ResourceType::Type type) {
49 return type == STYLESHEET || 87 return type == STYLESHEET ||
50 type == SCRIPT || 88 type == SCRIPT ||
51 type == IMAGE || 89 type == IMAGE ||
52 type == FONT_RESOURCE || 90 type == FONT_RESOURCE ||
53 type == SUB_RESOURCE || 91 type == SUB_RESOURCE ||
54 type == WORKER; 92 type == WORKER;
55 } 93 }
56 94
57 private: 95 private:
58 // Don't instantiate this class. 96 // Don't instantiate this class.
59 ResourceType(); 97 ResourceType();
60 ~ResourceType(); 98 ~ResourceType();
61 }; 99 };
62 #endif // WEBKIT_GLUE_RESOURCE_TYPE_H__ 100 #endif // WEBKIT_GLUE_RESOURCE_TYPE_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698