Revert of https://codereview.chromium.org/94133003/
[chromium-blink-merge.git] / webkit / common / resource_type.cc
blobfccaf7ea082566d7e53376b8e3c68f95cb8a698a
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 #include "webkit/common/resource_type.h"
7 #include "base/logging.h"
9 using blink::WebURLRequest;
11 // static
12 ResourceType::Type ResourceType::FromTargetType(
13 WebURLRequest::TargetType type) {
14 switch (type) {
15 case WebURLRequest::TargetIsMainFrame:
16 return ResourceType::MAIN_FRAME;
17 case WebURLRequest::TargetIsSubframe:
18 return ResourceType::SUB_FRAME;
19 case WebURLRequest::TargetIsSubresource:
20 return ResourceType::SUB_RESOURCE;
21 case WebURLRequest::TargetIsStyleSheet:
22 return ResourceType::STYLESHEET;
23 case WebURLRequest::TargetIsScript:
24 return ResourceType::SCRIPT;
25 case WebURLRequest::TargetIsFontResource:
26 return ResourceType::FONT_RESOURCE;
27 case WebURLRequest::TargetIsImage:
28 return ResourceType::IMAGE;
29 case WebURLRequest::TargetIsObject:
30 return ResourceType::OBJECT;
31 case WebURLRequest::TargetIsMedia:
32 return ResourceType::MEDIA;
33 case WebURLRequest::TargetIsWorker:
34 return ResourceType::WORKER;
35 case WebURLRequest::TargetIsSharedWorker:
36 return ResourceType::SHARED_WORKER;
37 case WebURLRequest::TargetIsPrefetch:
38 return ResourceType::PREFETCH;
39 case WebURLRequest::TargetIsFavicon:
40 return ResourceType::FAVICON;
41 case WebURLRequest::TargetIsXHR:
42 return ResourceType::XHR;
43 case WebURLRequest::TargetIsPing:
44 return ResourceType::PING;
45 default:
46 NOTREACHED();
47 return ResourceType::SUB_RESOURCE;