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

Unified Diff: chrome/browser/component_updater/test/url_request_post_interceptor.cc

Issue 15908002: Differential updates for components. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/component_updater/test/url_request_post_interceptor.cc
diff --git a/chrome/browser/component_updater/test/url_request_post_interceptor.cc b/chrome/browser/component_updater/test/url_request_post_interceptor.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f5917a276d3f4f9a2e84d42fa8d31d3df2bccbeb
--- /dev/null
+++ b/chrome/browser/component_updater/test/url_request_post_interceptor.cc
@@ -0,0 +1,68 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/component_updater/test/url_request_post_interceptor.h"
+
+#include "content/public/test/test_browser_thread.h"
+#include "net/url_request/url_request.h"
+#include "net/url_request/url_request_filter.h"
+#include "net/url_request/url_request_test_util.h"
+
+using content::BrowserThread;
+
+URLRequestPostInterceptor::URLRequestPostInterceptor(
+ RequestCounter* counter) : delegate_(new Delegate(counter)) {
+ BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
+ base::Bind(&Delegate::Register,
+ base::Unretained(delegate_)));
+}
+
+URLRequestPostInterceptor::~URLRequestPostInterceptor() {
+ BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
+ base::Bind(&Delegate::Unregister,
+ base::Unretained(delegate_)));
+}
+
+URLRequestPostInterceptor::Delegate::Delegate(
+ RequestCounter* counter) : counter_(counter) {
+}
+
+void URLRequestPostInterceptor::Delegate::Register() {
+ net::URLRequestFilter::GetInstance()->AddHostnameProtocolHandler(
+ "http", "localhost2",
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>(this));
+}
+
+void URLRequestPostInterceptor::Delegate::Unregister() {
+ net::URLRequestFilter::GetInstance()->
+ RemoveHostnameHandler("http", "localhost2");
+}
+
+net::URLRequestJob* URLRequestPostInterceptor::Delegate::MaybeCreateJob(
+ net::URLRequest* request,
+ net::NetworkDelegate* network_delegate) const {
+ CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ if (request->has_upload()) {
+ counter_->Trial(request);
+ return new URLRequestPingMockJob(request, network_delegate);
+ }
+ return NULL;
+}
+
cpu_(ooo_6.6-7.5) 2013/06/20 22:34:25 pingMockJob and related code, I think is not neede
Sorin Jianu 2013/06/20 23:51:59 Done.
+URLRequestPingMockJob::URLRequestPingMockJob(
+ net::URLRequest* request,
+ net::NetworkDelegate* network_delegate)
+ : net::URLRequestSimpleJob(request, network_delegate) {
+}
+
+int URLRequestPingMockJob::GetData(
+ std::string* mime_type,
+ std::string* charset,
+ std::string* data,
+ const net::CompletionCallback& callback) const {
+ mime_type->assign("text/plain");
+ charset->assign("US-ASCII");
+ data->assign(""); // There is no reason to have a response body.
+ return net::OK;
+}

Powered by Google App Engine
This is Rietveld 408576698