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

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

Issue 7941008: Cosmetic cleanups in chrome/browser/policy/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanups and IWYU fixit in policy code Created 9 years, 3 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/policy/testing_policy_url_fetcher_factory.h" 5 #include "chrome/browser/policy/testing_policy_url_fetcher_factory.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h"
9 #include "chrome/browser/policy/logging_work_scheduler.h" 8 #include "chrome/browser/policy/logging_work_scheduler.h"
9 #include "googleurl/src/gurl.h"
10 #include "googleurl/src/url_parse.h" 10 #include "googleurl/src/url_parse.h"
11 #include "net/http/http_request_headers.h" 11 #include "net/http/http_request_headers.h"
12 #include "net/url_request/url_request.h"
12 #include "net/url_request/url_request_status.h" 13 #include "net/url_request/url_request_status.h"
13 14
14 namespace { 15 namespace {
15 16
16 // Extracts the GET parameter by the name "request" from an URL. 17 // Extracts the GET parameter by the name "request" from an URL.
17 std::string GetRequestType(const GURL& url) { 18 std::string GetRequestType(const GURL& url) {
18 url_parse::Component query = url.parsed_for_possibly_invalid_spec().query; 19 url_parse::Component query = url.parsed_for_possibly_invalid_spec().query;
19 url_parse::Component key, value; 20 url_parse::Component key, value;
20 const char* url_spec = url.spec().c_str(); 21 const char* url_spec = url.spec().c_str();
21 while (url_parse::ExtractQueryKeyValue(url_spec, &query, &key, &value)) { 22 while (url_parse::ExtractQueryKeyValue(url_spec, &query, &key, &value)) {
(...skipping 12 matching lines...) Expand all
34 35
35 // An URLFetcher that calls back to its factory to figure out what to respond. 36 // An URLFetcher that calls back to its factory to figure out what to respond.
36 class TestingPolicyURLFetcher : public URLFetcher { 37 class TestingPolicyURLFetcher : public URLFetcher {
37 public: 38 public:
38 TestingPolicyURLFetcher( 39 TestingPolicyURLFetcher(
39 const base::WeakPtr<TestingPolicyURLFetcherFactory>& parent, 40 const base::WeakPtr<TestingPolicyURLFetcherFactory>& parent,
40 const GURL& url, 41 const GURL& url,
41 URLFetcher::RequestType request_type, 42 URLFetcher::RequestType request_type,
42 URLFetcher::Delegate* delegate); 43 URLFetcher::Delegate* delegate);
43 44
44 virtual void Start(); 45 virtual void Start() OVERRIDE;
45 void Respond(); 46 void Respond();
46 47
47 private: 48 private:
48 GURL url_; 49 GURL url_;
49 TestURLResponse response_; 50 TestURLResponse response_;
50 base::WeakPtr<TestingPolicyURLFetcherFactory> parent_; 51 base::WeakPtr<TestingPolicyURLFetcherFactory> parent_;
51 52
52 DISALLOW_COPY_AND_ASSIGN(TestingPolicyURLFetcher); 53 DISALLOW_COPY_AND_ASSIGN(TestingPolicyURLFetcher);
53 }; 54 };
54 55
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 URLFetcher* TestingPolicyURLFetcherFactory::CreateURLFetcher( 117 URLFetcher* TestingPolicyURLFetcherFactory::CreateURLFetcher(
117 int id, 118 int id,
118 const GURL& url, 119 const GURL& url,
119 URLFetcher::RequestType request_type, 120 URLFetcher::RequestType request_type,
120 URLFetcher::Delegate* delegate) { 121 URLFetcher::Delegate* delegate) {
121 return new TestingPolicyURLFetcher( 122 return new TestingPolicyURLFetcher(
122 weak_ptr_factory_.GetWeakPtr(), url, request_type, delegate); 123 weak_ptr_factory_.GetWeakPtr(), url, request_type, delegate);
123 } 124 }
124 125
125 } // namespace policy 126 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698