| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/search/instant_io_context.h" | 5 #include "chrome/browser/search/instant_io_context.h" |
| 6 | 6 |
| 7 #include "content/public/browser/browser_thread.h" | 7 #include "content/public/browser/browser_thread.h" |
| 8 #include "content/public/browser/resource_context.h" | 8 #include "content/public/browser/resource_context.h" |
| 9 #include "content/public/browser/resource_request_info.h" | 9 #include "content/public/browser/resource_request_info.h" |
| 10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 void InstantIOContext::SetUserDataOnIO( | 49 void InstantIOContext::SetUserDataOnIO( |
| 50 content::ResourceContext* resource_context, | 50 content::ResourceContext* resource_context, |
| 51 scoped_refptr<InstantIOContext> instant_io_context) { | 51 scoped_refptr<InstantIOContext> instant_io_context) { |
| 52 resource_context->SetUserData( | 52 resource_context->SetUserData( |
| 53 InstantIOContext::kInstantIOContextKeyName, | 53 InstantIOContext::kInstantIOContextKeyName, |
| 54 new base::UserDataAdapter<InstantIOContext>(instant_io_context)); | 54 new base::UserDataAdapter<InstantIOContext>(instant_io_context)); |
| 55 } | 55 } |
| 56 | 56 |
| 57 // static | 57 // static |
| 58 void InstantIOContext::AddInstantProcessOnIO( | 58 void InstantIOContext::AddInstantProcessOnIO( |
| 59 scoped_refptr<InstantIOContext> instant_io_context, int process_id) { | 59 scoped_refptr<InstantIOContext> instant_io_context, |
| 60 int process_id) { |
| 60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 61 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 61 instant_io_context->process_ids_.insert(process_id); | 62 instant_io_context->process_ids_.insert(process_id); |
| 62 } | 63 } |
| 63 | 64 |
| 64 // static | 65 // static |
| 65 void InstantIOContext::RemoveInstantProcessOnIO( | 66 void InstantIOContext::RemoveInstantProcessOnIO( |
| 66 scoped_refptr<InstantIOContext> instant_io_context, int process_id) { | 67 scoped_refptr<InstantIOContext> instant_io_context, int process_id) { |
| 67 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 68 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 68 instant_io_context->process_ids_.erase(process_id); | 69 instant_io_context->process_ids_.erase(process_id); |
| 69 } | 70 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 *url = GURL(); | 114 *url = GURL(); |
| 114 return false; | 115 return false; |
| 115 } | 116 } |
| 116 | 117 |
| 117 return instant_io_context->GetURLForMostVisitedItemID(most_visited_item_id, | 118 return instant_io_context->GetURLForMostVisitedItemID(most_visited_item_id, |
| 118 url); | 119 url); |
| 119 } | 120 } |
| 120 | 121 |
| 121 bool InstantIOContext::IsInstantProcess(int process_id) const { | 122 bool InstantIOContext::IsInstantProcess(int process_id) const { |
| 122 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 123 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 123 return process_ids_.count(process_id) != 0; | 124 return process_ids_.find(process_id) != process_ids_.end(); |
| 124 } | 125 } |
| 125 | 126 |
| 126 bool InstantIOContext::GetURLForMostVisitedItemID( | 127 bool InstantIOContext::GetURLForMostVisitedItemID( |
| 127 InstantRestrictedID most_visited_item_id, | 128 InstantRestrictedID most_visited_item_id, |
| 128 GURL* url) const { | 129 GURL* url) const { |
| 129 InstantMostVisitedItem item; | 130 InstantMostVisitedItem item; |
| 130 if (most_visited_item_cache_.GetItemWithRestrictedID(most_visited_item_id, | 131 if (most_visited_item_cache_.GetItemWithRestrictedID(most_visited_item_id, |
| 131 &item)) { | 132 &item)) { |
| 132 *url = item.url; | 133 *url = item.url; |
| 133 return true; | 134 return true; |
| 134 } | 135 } |
| 135 | 136 |
| 136 *url = GURL(); | 137 *url = GURL(); |
| 137 return false; | 138 return false; |
| 138 } | 139 } |
| OLD | NEW |