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

Unified Diff: chrome/browser/instant/instant_io_context.h

Issue 11896113: Add chrome-search: access from Instant overlay (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: include nit Created 7 years, 10 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/instant/instant_io_context.h
diff --git a/chrome/browser/instant/instant_io_context.h b/chrome/browser/instant/instant_io_context.h
new file mode 100644
index 0000000000000000000000000000000000000000..c5d3150f9c179b10a1e1adc902915d035e2e42b1
--- /dev/null
+++ b/chrome/browser/instant/instant_io_context.h
@@ -0,0 +1,57 @@
+// Copyright 2013 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.
+
+#ifndef CHROME_BROWSER_INSTANT_INSTANT_IO_CONTEXT_
+#define CHROME_BROWSER_INSTANT_INSTANT_IO_CONTEXT_
+
+#include <set>
+
+#include "base/basictypes.h"
+#include "base/supports_user_data.h"
+
+namespace content {
+class ResourceContext;
+}
+
+namespace net {
+class URLRequest;
+}
+
+// IO thread data held for Instant. This reflects the data held in
+// InstantService for use on the IO thread. Owned by ResourceContext
+// as user data.
+class InstantIOContext : public base::SupportsUserData::Data {
+ public:
+ InstantIOContext();
+ virtual ~InstantIOContext();
+
+ // Add and remove RenderProcessHost IDs that are associated with Instant
+ // processes. Used to keep process ids in sync with InstantService.
+ static void AddInstantProcessOnIO(content::ResourceContext* context,
+ int process_id);
+ static void RemoveInstantProcessOnIO(content::ResourceContext* context,
+ int process_id);
+ static void ClearInstantProcessesOnIO(content::ResourceContext* context);
+
+ // Determine if this chrome-search: request is coming from an Instant render
+ // process.
+ static bool ShouldServiceRequest(const net::URLRequest* request);
+
+ private:
+ // Check that |process_id| is in the known set of Instant processes, ie.
+ // |process_ids_|.
+ void AddInstantProcess(int process_id);
+ void RemoveInstantProcess(int process_id);
+ bool IsInstantProcess(int process_id) const;
+ void ClearInstantProcesses();
+
+ // The process ids associated with Instant processes. Mirror of the process
+ // ids in InstantService. Duplicated here for synchronous access on the IO
+ // thread.
+ std::set<int> process_ids_;
+
+ DISALLOW_COPY_AND_ASSIGN(InstantIOContext);
+};
+
+#endif // CHROME_BROWSER_INSTANT_INSTANT_IO_CONTEXT_

Powered by Google App Engine
This is Rietveld 408576698