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

Side by Side Diff: chrome/browser/policy/device_management_service_browsertest.cc

Issue 10834289: Split net::UploadData into two: for IPC and for upload handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "chrome/browser/policy/cloud_policy_constants.h" 8 #include "chrome/browser/policy/cloud_policy_constants.h"
9 #include "chrome/browser/policy/device_management_service.h" 9 #include "chrome/browser/policy/device_management_service.h"
10 #include "chrome/test/base/in_process_browser_test.h" 10 #include "chrome/test/base/in_process_browser_test.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // net::URLRequest::Interceptor overrides. 43 // net::URLRequest::Interceptor overrides.
44 virtual net::URLRequestJob* MaybeIntercept( 44 virtual net::URLRequestJob* MaybeIntercept(
45 net::URLRequest* request) OVERRIDE { 45 net::URLRequest* request) OVERRIDE {
46 em::DeviceManagementRequest dm_request; 46 em::DeviceManagementRequest dm_request;
47 net::UploadData* upload = request->get_upload_mutable(); 47 net::UploadData* upload = request->get_upload_mutable();
48 if (request->url().GetOrigin() == service_url_.GetOrigin() && 48 if (request->url().GetOrigin() == service_url_.GetOrigin() &&
49 request->url().path() == service_url_.path() && 49 request->url().path() == service_url_.path() &&
50 upload != NULL && 50 upload != NULL &&
51 upload->elements()->size() == 1) { 51 upload->elements()->size() == 1) {
52 std::string response_data; 52 std::string response_data;
53 ConstructResponse(upload->elements()->at(0).bytes(), &response_data); 53 ConstructResponse(upload->elements()->at(0).bytes(),
54 upload->elements()->at(0).bytes_length(),
55 &response_data);
54 return new net::URLRequestTestJob(request, 56 return new net::URLRequestTestJob(request,
55 net::URLRequestTestJob::test_headers(), 57 net::URLRequestTestJob::test_headers(),
56 response_data, 58 response_data,
57 true); 59 true);
58 } 60 }
59 61
60 return NULL; 62 return NULL;
61 } 63 }
62 64
63 private: 65 private:
64 void ConstructResponse(const std::vector<char>& request_data, 66 void ConstructResponse(const void* request_data,
darin (slow to review) 2012/08/15 17:49:55 nit: |const char*| instead since that's what Uploa
kinuko 2012/08/16 08:14:59 Done.
67 uint64 request_data_length,
65 std::string* response_data) { 68 std::string* response_data) {
66 em::DeviceManagementRequest request; 69 em::DeviceManagementRequest request;
67 ASSERT_TRUE(request.ParseFromArray(vector_as_array(&request_data), 70 ASSERT_TRUE(request.ParseFromArray(request_data, request_data_length));
68 request_data.size()));
69 em::DeviceManagementResponse response; 71 em::DeviceManagementResponse response;
70 if (request.has_register_request()) { 72 if (request.has_register_request()) {
71 response.mutable_register_response()->set_device_management_token( 73 response.mutable_register_response()->set_device_management_token(
72 "fake_token"); 74 "fake_token");
73 } else if (request.has_unregister_request()) { 75 } else if (request.has_unregister_request()) {
74 response.mutable_unregister_response(); 76 response.mutable_unregister_response();
75 } else if (request.has_policy_request()) { 77 } else if (request.has_policy_request()) {
76 response.mutable_policy_response()->add_response(); 78 response.mutable_policy_response()->add_response();
77 } else if (request.has_auto_enrollment_request()) { 79 } else if (request.has_auto_enrollment_request()) {
78 response.mutable_auto_enrollment_response(); 80 response.mutable_auto_enrollment_response();
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 MessageLoop::current()->Run(); 208 MessageLoop::current()->Run();
207 } 209 }
208 210
209 INSTANTIATE_TEST_CASE_P( 211 INSTANTIATE_TEST_CASE_P(
210 DeviceManagementServiceIntegrationTestInstance, 212 DeviceManagementServiceIntegrationTestInstance,
211 DeviceManagementServiceIntegrationTest, 213 DeviceManagementServiceIntegrationTest,
212 testing::Values(&DeviceManagementServiceIntegrationTest::InitCannedResponse, 214 testing::Values(&DeviceManagementServiceIntegrationTest::InitCannedResponse,
213 &DeviceManagementServiceIntegrationTest::InitTestServer)); 215 &DeviceManagementServiceIntegrationTest::InitTestServer));
214 216
215 } // namespace policy 217 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698