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

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

Issue 2647643004: Report nav timing 2 instance as soon as it's requested. (Closed)
Patch Set: make a copy of navigationTimingInfo for ResourceFetcher Created 3 years, 10 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 resourceRequest.setRequestContext(WebURLRequest::RequestContextForm); 166 resourceRequest.setRequestContext(WebURLRequest::RequestContextForm);
167 FetchRequest fetchRequest = 167 FetchRequest fetchRequest =
168 FetchRequest(resourceRequest, FetchInitiatorInfo()); 168 FetchRequest(resourceRequest, FetchInitiatorInfo());
169 Platform::current()->getURLLoaderMockFactory()->registerURL( 169 Platform::current()->getURLLoaderMockFactory()->registerURL(
170 url, WebURLResponse(), ""); 170 url, WebURLResponse(), "");
171 Resource* resource = 171 Resource* resource =
172 RawResource::fetchMainResource(fetchRequest, fetcher, SubstituteData()); 172 RawResource::fetchMainResource(fetchRequest, fetcher, SubstituteData());
173 resource->responseReceived(response, nullptr); 173 resource->responseReceived(response, nullptr);
174 EXPECT_EQ(resource->getType(), Resource::MainResource); 174 EXPECT_EQ(resource->getType(), Resource::MainResource);
175 175
176 ResourceTimingInfo* navigationTimingInfo = fetcher->getNavigationTimingInfo(); 176 std::unique_ptr<ResourceTimingInfo> navigationTimingInfo =
177 fetcher->getNavigationTimingInfo();
177 ASSERT_TRUE(navigationTimingInfo); 178 ASSERT_TRUE(navigationTimingInfo);
178 long long encodedDataLength = 123; 179 long long encodedDataLength = 123;
179 resource->loader()->didFinishLoading(0.0, encodedDataLength, 0); 180 resource->loader()->didFinishLoading(0.0, encodedDataLength, 0);
180 EXPECT_EQ(navigationTimingInfo->transferSize(), encodedDataLength); 181 EXPECT_EQ(navigationTimingInfo->transferSize(), encodedDataLength);
181 182
182 // When there are redirects. 183 // When there are redirects.
183 KURL redirectURL(ParsedURLString, "http://127.0.0.1:8000/redirect.html"); 184 KURL redirectURL(ParsedURLString, "http://127.0.0.1:8000/redirect.html");
184 ResourceResponse redirectResponse; 185 ResourceResponse redirectResponse;
185 redirectResponse.setURL(redirectURL); 186 redirectResponse.setURL(redirectURL);
186 redirectResponse.setHTTPStatusCode(200); 187 redirectResponse.setHTTPStatusCode(200);
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 // Resource created by parser on the second fetcher 649 // Resource created by parser on the second fetcher
649 FetchRequest fetchRequest2 = FetchRequest(url, FetchInitiatorInfo()); 650 FetchRequest fetchRequest2 = FetchRequest(url, FetchInitiatorInfo());
650 Resource* newResource2 = MockResource::fetch(fetchRequest2, fetcher2); 651 Resource* newResource2 = MockResource::fetch(fetchRequest2, fetcher2);
651 Persistent<MockResourceClient> client2 = new MockResourceClient(newResource2); 652 Persistent<MockResourceClient> client2 = new MockResourceClient(newResource2);
652 EXPECT_EQ(resource, newResource2); 653 EXPECT_EQ(resource, newResource2);
653 EXPECT_FALSE(fetcher2->isFetching()); 654 EXPECT_FALSE(fetcher2->isFetching());
654 Platform::current()->getURLLoaderMockFactory()->serveAsynchronousRequests(); 655 Platform::current()->getURLLoaderMockFactory()->serveAsynchronousRequests();
655 } 656 }
656 657
657 } // namespace blink 658 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698