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

Side by Side Diff: third_party/WebKit/Source/core/fetch/ResourceFetcherTest.cpp

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 years, 6 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
OLDNEW
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 28 matching lines...) Expand all
39 #include "platform/exported/WrappedResourceResponse.h" 39 #include "platform/exported/WrappedResourceResponse.h"
40 #include "platform/heap/Handle.h" 40 #include "platform/heap/Handle.h"
41 #include "platform/network/ResourceRequest.h" 41 #include "platform/network/ResourceRequest.h"
42 #include "platform/testing/URLTestHelpers.h" 42 #include "platform/testing/URLTestHelpers.h"
43 #include "platform/weborigin/KURL.h" 43 #include "platform/weborigin/KURL.h"
44 #include "public/platform/Platform.h" 44 #include "public/platform/Platform.h"
45 #include "public/platform/WebTaskRunner.h" 45 #include "public/platform/WebTaskRunner.h"
46 #include "public/platform/WebURLLoaderMockFactory.h" 46 #include "public/platform/WebURLLoaderMockFactory.h"
47 #include "public/platform/WebURLResponse.h" 47 #include "public/platform/WebURLResponse.h"
48 #include "testing/gtest/include/gtest/gtest.h" 48 #include "testing/gtest/include/gtest/gtest.h"
49 #include "wtf/PtrUtil.h"
50 #include <memory>
49 51
50 namespace blink { 52 namespace blink {
51 53
52 namespace { 54 namespace {
53 55
54 class MockTaskRunner : public blink::WebTaskRunner { 56 class MockTaskRunner : public blink::WebTaskRunner {
55 void postTask(const WebTraceLocation&, Task*) override { } 57 void postTask(const WebTraceLocation&, Task*) override { }
56 void postDelayedTask(const WebTraceLocation&, Task*, double) override { } 58 void postDelayedTask(const WebTraceLocation&, Task*, double) override { }
57 WebTaskRunner* clone() override { return nullptr; } 59 WebTaskRunner* clone() override { return nullptr; }
58 double virtualTimeSeconds() const override { return 0.0; } 60 double virtualTimeSeconds() const override { return 0.0; }
(...skipping 17 matching lines...) Expand all
76 WebTaskRunner* loadingTaskRunner() const override { return m_runner.get(); } 78 WebTaskRunner* loadingTaskRunner() const override { return m_runner.get(); }
77 79
78 void setCachePolicy(CachePolicy policy) { m_policy = policy; } 80 void setCachePolicy(CachePolicy policy) { m_policy = policy; }
79 CachePolicy getCachePolicy() const override { return m_policy; } 81 CachePolicy getCachePolicy() const override { return m_policy; }
80 void setLoadComplete(bool complete) { m_complete = complete; } 82 void setLoadComplete(bool complete) { m_complete = complete; }
81 bool isLoadComplete() const override { return m_complete; } 83 bool isLoadComplete() const override { return m_complete; }
82 84
83 private: 85 private:
84 ResourceFetcherTestMockFetchContext() 86 ResourceFetcherTestMockFetchContext()
85 : m_policy(CachePolicyVerify) 87 : m_policy(CachePolicyVerify)
86 , m_runner(adoptPtr(new MockTaskRunner)) 88 , m_runner(wrapUnique(new MockTaskRunner))
87 , m_complete(false) 89 , m_complete(false)
88 { } 90 { }
89 91
90 CachePolicy m_policy; 92 CachePolicy m_policy;
91 OwnPtr<MockTaskRunner> m_runner; 93 std::unique_ptr<MockTaskRunner> m_runner;
92 bool m_complete; 94 bool m_complete;
93 }; 95 };
94 96
95 class ResourceFetcherTest : public ::testing::Test { 97 class ResourceFetcherTest : public ::testing::Test {
96 }; 98 };
97 99
98 class TestResourceFactory : public ResourceFactory { 100 class TestResourceFactory : public ResourceFactory {
99 public: 101 public:
100 TestResourceFactory(Resource::Type type = Resource::Raw) 102 TestResourceFactory(Resource::Type type = Resource::Raw)
101 : ResourceFactory(type) { } 103 : ResourceFactory(type) { }
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 class ServeRequestsOnCompleteClient final : public GarbageCollectedFinalized<Ser veRequestsOnCompleteClient>, public RawResourceClient { 349 class ServeRequestsOnCompleteClient final : public GarbageCollectedFinalized<Ser veRequestsOnCompleteClient>, public RawResourceClient {
348 public: 350 public:
349 void notifyFinished(Resource*) override 351 void notifyFinished(Resource*) override
350 { 352 {
351 Platform::current()->getURLLoaderMockFactory()->serveAsynchronousRequest s(); 353 Platform::current()->getURLLoaderMockFactory()->serveAsynchronousRequest s();
352 } 354 }
353 355
354 // No callbacks should be received except for the notifyFinished() 356 // No callbacks should be received except for the notifyFinished()
355 // triggered by ResourceLoader::cancel(). 357 // triggered by ResourceLoader::cancel().
356 void dataSent(Resource*, unsigned long long, unsigned long long) override { ASSERT_TRUE(false); } 358 void dataSent(Resource*, unsigned long long, unsigned long long) override { ASSERT_TRUE(false); }
357 void responseReceived(Resource*, const ResourceResponse&, PassOwnPtr<WebData ConsumerHandle>) override { ASSERT_TRUE(false); } 359 void responseReceived(Resource*, const ResourceResponse&, std::unique_ptr<We bDataConsumerHandle>) override { ASSERT_TRUE(false); }
358 void setSerializedCachedMetadata(Resource*, const char*, size_t) override { ASSERT_TRUE(false); } 360 void setSerializedCachedMetadata(Resource*, const char*, size_t) override { ASSERT_TRUE(false); }
359 void dataReceived(Resource*, const char*, size_t) override { ASSERT_TRUE(fal se); } 361 void dataReceived(Resource*, const char*, size_t) override { ASSERT_TRUE(fal se); }
360 void redirectReceived(Resource*, ResourceRequest&, const ResourceResponse&) override { ASSERT_TRUE(false); } 362 void redirectReceived(Resource*, ResourceRequest&, const ResourceResponse&) override { ASSERT_TRUE(false); }
361 void dataDownloaded(Resource*, int) override { ASSERT_TRUE(false); } 363 void dataDownloaded(Resource*, int) override { ASSERT_TRUE(false); }
362 void didReceiveResourceTiming(Resource*, const ResourceTimingInfo&) override { ASSERT_TRUE(false); } 364 void didReceiveResourceTiming(Resource*, const ResourceTimingInfo&) override { ASSERT_TRUE(false); }
363 365
364 DEFINE_INLINE_TRACE() {} 366 DEFINE_INLINE_TRACE() {}
365 367
366 String debugName() const override { return "ServeRequestsOnCompleteClient"; } 368 String debugName() const override { return "ServeRequestsOnCompleteClient"; }
367 }; 369 };
(...skipping 15 matching lines...) Expand all
383 FetchRequest fetchRequest = FetchRequest(url, FetchInitiatorInfo()); 385 FetchRequest fetchRequest = FetchRequest(url, FetchInitiatorInfo());
384 Resource* resource = fetcher->requestResource(fetchRequest, TestResourceFact ory(Resource::Raw)); 386 Resource* resource = fetcher->requestResource(fetchRequest, TestResourceFact ory(Resource::Raw));
385 Persistent<ServeRequestsOnCompleteClient> client = new ServeRequestsOnComple teClient(); 387 Persistent<ServeRequestsOnCompleteClient> client = new ServeRequestsOnComple teClient();
386 resource->addClient(client); 388 resource->addClient(client);
387 resource->loader()->cancel(); 389 resource->loader()->cancel();
388 resource->removeClient(client); 390 resource->removeClient(client);
389 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url); 391 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url);
390 } 392 }
391 393
392 } // namespace blink 394 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp ('k') | third_party/WebKit/Source/core/fetch/ResourceLoader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698