OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/process_util.h" | 8 #include "base/process_util.h" |
9 #include "chrome/browser/renderer_host/renderer_security_policy.h" | 9 #include "chrome/browser/renderer_host/renderer_security_policy.h" |
10 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 10 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
11 #include "chrome/common/chrome_plugin_lib.h" | 11 #include "chrome/common/chrome_plugin_lib.h" |
12 #include "chrome/common/render_messages.h" | 12 #include "chrome/common/render_messages.h" |
13 #include "net/url_request/url_request.h" | 13 #include "net/url_request/url_request.h" |
14 #include "net/url_request/url_request_job.h" | 14 #include "net/url_request/url_request_job.h" |
15 #include "net/url_request/url_request_test_job.h" | 15 #include "net/url_request/url_request_test_job.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "webkit/glue/webappcachecontext.h" |
17 | 18 |
18 static int RequestIDForMessage(const IPC::Message& msg) { | 19 static int RequestIDForMessage(const IPC::Message& msg) { |
19 int request_id = -1; | 20 int request_id = -1; |
20 switch (msg.type()) { | 21 switch (msg.type()) { |
21 case ViewMsg_Resource_UploadProgress::ID: | 22 case ViewMsg_Resource_UploadProgress::ID: |
22 case ViewMsg_Resource_ReceivedResponse::ID: | 23 case ViewMsg_Resource_ReceivedResponse::ID: |
23 case ViewMsg_Resource_ReceivedRedirect::ID: | 24 case ViewMsg_Resource_ReceivedRedirect::ID: |
24 case ViewMsg_Resource_DataReceived::ID: | 25 case ViewMsg_Resource_DataReceived::ID: |
25 case ViewMsg_Resource_RequestComplete::ID: | 26 case ViewMsg_Resource_RequestComplete::ID: |
26 request_id = IPC::MessageIterator(msg).NextInt(); | 27 request_id = IPC::MessageIterator(msg).NextInt(); |
27 break; | 28 break; |
28 } | 29 } |
29 return request_id; | 30 return request_id; |
30 } | 31 } |
31 | 32 |
32 static ViewHostMsg_Resource_Request CreateResourceRequest(const char* method, | 33 static ViewHostMsg_Resource_Request CreateResourceRequest(const char* method, |
33 const GURL& url) { | 34 const GURL& url) { |
34 ViewHostMsg_Resource_Request request; | 35 ViewHostMsg_Resource_Request request; |
35 request.method = std::string(method); | 36 request.method = std::string(method); |
36 request.url = url; | 37 request.url = url; |
37 request.policy_url = url; // bypass third-party cookie blocking | 38 request.policy_url = url; // bypass third-party cookie blocking |
38 // init the rest to default values to prevent getting UMR. | 39 // init the rest to default values to prevent getting UMR. |
39 request.frame_origin = "null"; | 40 request.frame_origin = "null"; |
40 request.main_frame_origin = "null"; | 41 request.main_frame_origin = "null"; |
41 request.load_flags = 0; | 42 request.load_flags = 0; |
42 request.origin_pid = 0; | 43 request.origin_pid = 0; |
43 request.resource_type = ResourceType::SUB_RESOURCE; | 44 request.resource_type = ResourceType::SUB_RESOURCE; |
44 request.request_context = 0; | 45 request.request_context = 0; |
| 46 request.app_cache_context_id = WebAppCacheContext::kNoAppCacheContextId; |
45 return request; | 47 return request; |
46 } | 48 } |
47 | 49 |
48 // We may want to move this to a shared space if it is useful for something else | 50 // We may want to move this to a shared space if it is useful for something else |
49 class ResourceIPCAccumulator { | 51 class ResourceIPCAccumulator { |
50 public: | 52 public: |
51 void AddMessage(const IPC::Message& msg) { | 53 void AddMessage(const IPC::Message& msg) { |
52 messages_.push_back(msg); | 54 messages_.push_back(msg); |
53 } | 55 } |
54 | 56 |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 EXPECT_EQ(URLRequestStatus::CANCELED, status.status()); | 644 EXPECT_EQ(URLRequestStatus::CANCELED, status.status()); |
643 EXPECT_EQ(net::ERR_INSUFFICIENT_RESOURCES, status.os_error()); | 645 EXPECT_EQ(net::ERR_INSUFFICIENT_RESOURCES, status.os_error()); |
644 } | 646 } |
645 | 647 |
646 // The final 2 requests should have succeeded. | 648 // The final 2 requests should have succeeded. |
647 CheckSuccessfulRequest(msgs[kMaxRequests + 2], | 649 CheckSuccessfulRequest(msgs[kMaxRequests + 2], |
648 URLRequestTestJob::test_data_2()); | 650 URLRequestTestJob::test_data_2()); |
649 CheckSuccessfulRequest(msgs[kMaxRequests + 3], | 651 CheckSuccessfulRequest(msgs[kMaxRequests + 3], |
650 URLRequestTestJob::test_data_2()); | 652 URLRequestTestJob::test_data_2()); |
651 } | 653 } |
OLD | NEW |