| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 EXPECT_EQ(0u, memoryCache()->size()); | 169 EXPECT_EQ(0u, memoryCache()->size()); |
| 170 | 170 |
| 171 const char data[6] = "abcde"; | 171 const char data[6] = "abcde"; |
| 172 resource1->appendData(data, 3u); | 172 resource1->appendData(data, 3u); |
| 173 resource1->finish(); | 173 resource1->finish(); |
| 174 Persistent<MockResourceClient> client = new MockResourceClient(resource2); | 174 Persistent<MockResourceClient> client = new MockResourceClient(resource2); |
| 175 resource2->appendData(data, 4u); | 175 resource2->appendData(data, 4u); |
| 176 resource2->finish(); | 176 resource2->finish(); |
| 177 | 177 |
| 178 Platform::current()->currentThread()->getWebTaskRunner()->postTask( | 178 Platform::current()->currentThread()->getWebTaskRunner()->postTask( |
| 179 BLINK_FROM_HERE, WTF::bind(&runTask1, wrapPersistent(resource1), | 179 BLINK_FROM_HERE, |
| 180 wrapPersistent(resource2))); | 180 WTF::bind(&runTask1, wrapPersistent(resource1), |
| 181 wrapPersistent(resource2))); |
| 181 Platform::current()->currentThread()->getWebTaskRunner()->postTask( | 182 Platform::current()->currentThread()->getWebTaskRunner()->postTask( |
| 182 BLINK_FROM_HERE, | 183 BLINK_FROM_HERE, |
| 183 WTF::bind(&runTask2, | 184 WTF::bind(&runTask2, |
| 184 resource1->encodedSize() + resource1->overheadSize() + | 185 resource1->encodedSize() + resource1->overheadSize() + |
| 185 resource2->encodedSize() + resource2->overheadSize())); | 186 resource2->encodedSize() + resource2->overheadSize())); |
| 186 static_cast<TestingPlatformSupportWithMockScheduler*>(Platform::current()) | 187 static_cast<TestingPlatformSupportWithMockScheduler*>(Platform::current()) |
| 187 ->runUntilIdle(); | 188 ->runUntilIdle(); |
| 188 } | 189 } |
| 189 | 190 |
| 190 // Verified that when ordering a prune in a runLoop task, the prune | 191 // Verified that when ordering a prune in a runLoop task, the prune |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 | 338 |
| 338 FakeResource* resource2 = FakeResource::create( | 339 FakeResource* resource2 = FakeResource::create( |
| 339 ResourceRequest("http://test/resource"), Resource::Raw); | 340 ResourceRequest("http://test/resource"), Resource::Raw); |
| 340 resource2->setCacheIdentifier("foo"); | 341 resource2->setCacheIdentifier("foo"); |
| 341 memoryCache()->add(resource2); | 342 memoryCache()->add(resource2); |
| 342 EXPECT_TRUE(memoryCache()->contains(resource1)); | 343 EXPECT_TRUE(memoryCache()->contains(resource1)); |
| 343 EXPECT_TRUE(memoryCache()->contains(resource2)); | 344 EXPECT_TRUE(memoryCache()->contains(resource2)); |
| 344 | 345 |
| 345 const KURL url = KURL(ParsedURLString, "http://test/resource"); | 346 const KURL url = KURL(ParsedURLString, "http://test/resource"); |
| 346 EXPECT_EQ(resource1, memoryCache()->resourceForURL(url)); | 347 EXPECT_EQ(resource1, memoryCache()->resourceForURL(url)); |
| 347 EXPECT_EQ(resource1, memoryCache()->resourceForURL( | 348 EXPECT_EQ(resource1, |
| 348 url, memoryCache()->defaultCacheIdentifier())); | 349 memoryCache()->resourceForURL( |
| 350 url, memoryCache()->defaultCacheIdentifier())); |
| 349 EXPECT_EQ(resource2, memoryCache()->resourceForURL(url, "foo")); | 351 EXPECT_EQ(resource2, memoryCache()->resourceForURL(url, "foo")); |
| 350 EXPECT_EQ(0, memoryCache()->resourceForURL(KURL())); | 352 EXPECT_EQ(0, memoryCache()->resourceForURL(KURL())); |
| 351 | 353 |
| 352 FakeResource* resource3 = FakeResource::create( | 354 FakeResource* resource3 = FakeResource::create( |
| 353 ResourceRequest("http://test/resource"), Resource::Raw); | 355 ResourceRequest("http://test/resource"), Resource::Raw); |
| 354 resource3->setCacheIdentifier("foo"); | 356 resource3->setCacheIdentifier("foo"); |
| 355 memoryCache()->remove(resource2); | 357 memoryCache()->remove(resource2); |
| 356 memoryCache()->add(resource3); | 358 memoryCache()->add(resource3); |
| 357 EXPECT_TRUE(memoryCache()->contains(resource1)); | 359 EXPECT_TRUE(memoryCache()->contains(resource1)); |
| 358 EXPECT_FALSE(memoryCache()->contains(resource2)); | 360 EXPECT_FALSE(memoryCache()->contains(resource2)); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 FakeResource* resource2 = | 395 FakeResource* resource2 = |
| 394 FakeResource::create(ResourceRequest(url2), Resource::Raw); | 396 FakeResource::create(ResourceRequest(url2), Resource::Raw); |
| 395 memoryCache()->add(resource2); | 397 memoryCache()->add(resource2); |
| 396 EXPECT_TRUE(memoryCache()->contains(resource2)); | 398 EXPECT_TRUE(memoryCache()->contains(resource2)); |
| 397 | 399 |
| 398 memoryCache()->removeURLFromCache(url2); | 400 memoryCache()->removeURLFromCache(url2); |
| 399 EXPECT_FALSE(memoryCache()->contains(resource2)); | 401 EXPECT_FALSE(memoryCache()->contains(resource2)); |
| 400 } | 402 } |
| 401 | 403 |
| 402 } // namespace blink | 404 } // namespace blink |
| OLD | NEW |