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

Unified Diff: components/policy/core/common/cloud/policy_header_io_helper.h

Issue 303993005: Add browser test for ChromeResourceDispatcherHostDelegate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix use-after-free of ResourceDispatcherHostDelegate in test. Created 6 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: components/policy/core/common/cloud/policy_header_io_helper.h
diff --git a/components/policy/core/common/cloud/policy_header_io_helper.h b/components/policy/core/common/cloud/policy_header_io_helper.h
index 01a0765f292b5e769f16dc7458b9129e3ac2431e..2996691299691f0951c8b9038e5fa41861a48e57 100644
--- a/components/policy/core/common/cloud/policy_header_io_helper.h
+++ b/components/policy/core/common/cloud/policy_header_io_helper.h
@@ -10,6 +10,7 @@
#include "base/memory/ref_counted.h"
#include "base/sequenced_task_runner.h"
#include "components/policy/policy_export.h"
+#include "url/gurl.h"
namespace net {
class URLRequest;
@@ -31,9 +32,10 @@ class POLICY_EXPORT PolicyHeaderIOHelper {
const scoped_refptr<base::SequencedTaskRunner>& task_runner);
~PolicyHeaderIOHelper();
- // Sets any necessary policy headers on the passed request. Should be invoked
- // only from the I/O thread.
- void AddPolicyHeaders(net::URLRequest* request) const;
+ // Sets any necessary policy headers for the specified URL on the passed
+ // request. Should be invoked only from the I/O thread.
+ void AddPolicyHeaders(const GURL& url,
+ net::URLRequest* request) const;
// API invoked when the header changes. Can be called from any thread - calls
// are marshalled via the TaskRunner to run on the appropriate thread.
@@ -41,10 +43,18 @@ class POLICY_EXPORT PolicyHeaderIOHelper {
// outgoing requests.
void UpdateHeader(const std::string& new_header);
+ // Test-only routine used to inject the server URL at runtime - this is
+ // required because PolicyHeaderIOHelper is created very early in BrowserTest
+ // initialization, before we startup the EmbeddedTestServer.
+ void SetServerURLForTest(const std::string& server_url);
+
private:
// API invoked via the TaskRunner to update the header.
void UpdateHeaderOnIOThread(const std::string& new_header);
+ // Helper routine invoked via the TaskRunner to update the cached server URL.
+ void SetServerURLOnIOThread(const std::string& new_header);
+
// The URL we should add policy headers to.
std::string server_url_;

Powered by Google App Engine
This is Rietveld 408576698