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

Side by Side Diff: content/public/common/resource_type.h

Issue 425653002: content: ResourceType cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: REBASE Created 6 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 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_PUBLIC_COMMON_RESOURCE_TYPE_H_ 5 #ifndef CONTENT_PUBLIC_COMMON_RESOURCE_TYPE_H_
6 #define CONTENT_PUBLIC_COMMON_RESOURCE_TYPE_H_ 6 #define CONTENT_PUBLIC_COMMON_RESOURCE_TYPE_H_
7 7
8 #include "base/macros.h"
9 #include "content/common/content_export.h" 8 #include "content/common/content_export.h"
10 #include "third_party/WebKit/public/platform/WebURLRequest.h"
11 9
12 namespace content { 10 namespace content {
13 11
14 class CONTENT_EXPORT ResourceType { 12 // Used in histograms, so please add new types at the end, and rename unused
15 public: 13 // entries to RESOURCETYPE_UNUSED_0, etc...
16 // Used in histograms, so please add new types at the end, and rename unused 14 enum ResourceType {
17 // entries to RESOURCETYPE_UNUSED_0, etc... 15 RESOURCE_TYPE_MAIN_FRAME = 0, // top level page
18 enum Type { 16 RESOURCE_TYPE_SUB_FRAME, // frame or iframe
19 MAIN_FRAME = 0, // top level page 17 RESOURCE_TYPE_STYLESHEET, // a CSS stylesheet
20 SUB_FRAME, // frame or iframe 18 RESOURCE_TYPE_SCRIPT, // an external script
21 STYLESHEET, // a CSS stylesheet 19 RESOURCE_TYPE_IMAGE, // an image (jpg/gif/png/etc)
22 SCRIPT, // an external script 20 RESOURCE_TYPE_FONT_RESOURCE, // a font
23 IMAGE, // an image (jpg/gif/png/etc) 21 RESOURCE_TYPE_SUB_RESOURCE, // an "other" subresource.
24 FONT_RESOURCE, // a font 22 RESOURCE_TYPE_OBJECT, // an object (or embed) tag for a plugin,
25 SUB_RESOURCE, // an "other" subresource. 23 // or a resource that a plugin requested.
26 OBJECT, // an object (or embed) tag for a plugin, 24 RESOURCE_TYPE_MEDIA, // a media resource.
27 // or a resource that a plugin requested. 25 RESOURCE_TYPE_WORKER, // the main resource of a dedicated worker.
28 MEDIA, // a media resource. 26 RESOURCE_TYPE_SHARED_WORKER, // the main resource of a shared worker.
29 WORKER, // the main resource of a dedicated worker. 27 RESOURCE_TYPE_PREFETCH, // an explicitly requested prefetch
30 SHARED_WORKER, // the main resource of a shared worker. 28 RESOURCE_TYPE_FAVICON, // a favicon
31 PREFETCH, // an explicitly requested prefetch 29 RESOURCE_TYPE_XHR, // a XMLHttpRequest
32 FAVICON, // a favicon 30 RESOURCE_TYPE_PING, // a ping request for <a ping>
33 XHR, // a XMLHttpRequest 31 RESOURCE_TYPE_SERVICE_WORKER, // the main resource of a service worker.
34 PING, // a ping request for <a ping> 32 RESOURCE_TYPE_LAST_TYPE
35 SERVICE_WORKER, // the main resource of a service worker. 33 };
36 LAST_TYPE // Place holder so we don't need to change ValidType
37 // everytime.
38 };
39 34
40 static Type FromWebURLRequest(const blink::WebURLRequest& request); 35 CONTENT_EXPORT bool IsResourceTypeFrame(ResourceType type);
41
42 static bool ValidType(int32 type) {
43 return type >= MAIN_FRAME && type < LAST_TYPE;
44 }
45
46 static Type FromInt(int32 type) {
47 return static_cast<Type>(type);
48 }
49
50 static bool IsFrame(ResourceType::Type type) {
51 return type == MAIN_FRAME || type == SUB_FRAME;
52 }
53
54 static bool IsSharedWorker(ResourceType::Type type) {
55 return type == SHARED_WORKER;
56 }
57
58 static bool IsServiceWorker(ResourceType::Type type) {
59 return type == SERVICE_WORKER;
60 }
61
62 static bool IsSubresource(ResourceType::Type type) {
63 return type == STYLESHEET ||
64 type == SCRIPT ||
65 type == IMAGE ||
66 type == FONT_RESOURCE ||
67 type == SUB_RESOURCE ||
68 type == WORKER ||
69 type == XHR;
70 }
71
72 private:
73 DISALLOW_COPY_AND_ASSIGN(ResourceType);
74 };
75 36
76 } // namespace content 37 } // namespace content
77 38
78 #endif // CONTENT_PUBLIC_COMMON_RESOURCE_TYPE_H_ 39 #endif // CONTENT_PUBLIC_COMMON_RESOURCE_TYPE_H_
OLDNEW
« no previous file with comments | « content/public/child/resource_dispatcher_delegate.h ('k') | content/public/common/resource_type.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698