IndexedDB: fsync after transactions.
[chromium-blink-merge.git] / webkit / common / resource_type.h
blob44fb4843308f4b2ae77506bb8ae26a63aeff88a9
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
3 // found in the LICENSE file.
5 #ifndef WEBKIT_COMMON_RESOURCE_TYPE_H__
6 #define WEBKIT_COMMON_RESOURCE_TYPE_H__
8 #include "base/basictypes.h"
9 #include "third_party/WebKit/public/platform/WebURLRequest.h"
10 #include "webkit/common/webkit_common_export.h"
12 class ResourceType {
13 public:
14 // Used in histograms, so please add new types at the end, and rename unused
15 // entries to RESOURCETYPE_UNUSED_0, etc...
16 enum Type {
17 MAIN_FRAME = 0, // top level page
18 SUB_FRAME, // frame or iframe
19 STYLESHEET, // a CSS stylesheet
20 SCRIPT, // an external script
21 IMAGE, // an image (jpg/gif/png/etc)
22 FONT_RESOURCE, // a font
23 SUB_RESOURCE, // an "other" subresource.
24 OBJECT, // an object (or embed) tag for a plugin,
25 // or a resource that a plugin requested.
26 MEDIA, // a media resource.
27 WORKER, // the main resource of a dedicated worker.
28 SHARED_WORKER, // the main resource of a shared worker.
29 PREFETCH, // an explicitly requested prefetch
30 FAVICON, // a favicon
31 XHR, // a XMLHttpRequest
32 PING, // a ping request for <a ping>
33 SERVICE_WORKER, // the main resource of a service worker.
34 LAST_TYPE // Place holder so we don't need to change ValidType
35 // everytime.
38 static bool ValidType(int32 type) {
39 return type >= MAIN_FRAME && type < LAST_TYPE;
42 static Type FromInt(int32 type) {
43 return static_cast<Type>(type);
46 WEBKIT_COMMON_EXPORT static Type FromTargetType(
47 blink::WebURLRequest::TargetType type);
49 static bool IsFrame(ResourceType::Type type) {
50 return type == MAIN_FRAME || type == SUB_FRAME;
53 static bool IsSharedWorker(ResourceType::Type type) {
54 return type == SHARED_WORKER;
57 static bool IsSubresource(ResourceType::Type type) {
58 return type == STYLESHEET ||
59 type == SCRIPT ||
60 type == IMAGE ||
61 type == FONT_RESOURCE ||
62 type == SUB_RESOURCE ||
63 type == WORKER ||
64 type == XHR;
67 private:
68 // Don't instantiate this class.
69 ResourceType();
70 ~ResourceType();
72 #endif // WEBKIT_COMMON_RESOURCE_TYPE_H__