OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014, Google Inc. All rights reserved. | 2 * Copyright (c) 2014, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 Resource* resourceFromResourceResponse(ResourceResponse response, Resource::
Type type = Resource::Raw) | 77 Resource* resourceFromResourceResponse(ResourceResponse response, Resource::
Type type = Resource::Raw) |
78 { | 78 { |
79 if (response.url().isNull()) | 79 if (response.url().isNull()) |
80 response.setURL(KURL(ParsedURLString, kResourceURL)); | 80 response.setURL(KURL(ParsedURLString, kResourceURL)); |
81 Resource* resource = nullptr; | 81 Resource* resource = nullptr; |
82 switch (type) { | 82 switch (type) { |
83 case Resource::Raw: | 83 case Resource::Raw: |
84 resource = Resource::create(ResourceRequest(response.url()), type); | 84 resource = Resource::create(ResourceRequest(response.url()), type); |
85 break; | 85 break; |
86 case Resource::Image: | 86 case Resource::Image: |
87 resource = ImageResource::create(ResourceRequest(response.url()), nu
llptr); | 87 resource = ImageResource::create(ResourceRequest(response.url())); |
88 break; | 88 break; |
89 default: | 89 default: |
90 EXPECT_TRUE(false) << "'Unreachable' code was reached"; | 90 EXPECT_TRUE(false) << "'Unreachable' code was reached"; |
91 return nullptr; | 91 return nullptr; |
92 } | 92 } |
93 resource->setResponse(response); | 93 resource->setResponse(response); |
94 resource->finish(); | 94 resource->finish(); |
95 // Because we didn't give any real data, an image will have set its | 95 // Because we didn't give any real data, an image will have set its |
96 // status to DecodeError. Override it so the resource is cacaheable | 96 // status to DecodeError. Override it so the resource is cacaheable |
97 // for testing purposes. | 97 // for testing purposes. |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 firstResource->finish(); | 562 firstResource->finish(); |
563 memoryCache()->add(firstResource); | 563 memoryCache()->add(firstResource); |
564 | 564 |
565 advanceClock(500.); | 565 advanceClock(500.); |
566 | 566 |
567 Resource* fetched = fetch(); | 567 Resource* fetched = fetch(); |
568 EXPECT_EQ(firstResource, fetched); | 568 EXPECT_EQ(firstResource, fetched); |
569 } | 569 } |
570 | 570 |
571 } // namespace blink | 571 } // namespace blink |
OLD | NEW |