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

Side by Side Diff: net/http/http_cache.cc

Issue 27149: Http cache: When adding a transaction to a cache entry,... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 9 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
« no previous file with comments | « no previous file | net/http/http_cache_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "net/http/http_cache.h" 5 #include "net/http/http_cache.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 return ERR_IO_PENDING; 1278 return ERR_IO_PENDING;
1279 } 1279 }
1280 } else { 1280 } else {
1281 // transaction needs read access to the entry 1281 // transaction needs read access to the entry
1282 entry->readers.push_back(trans); 1282 entry->readers.push_back(trans);
1283 } 1283 }
1284 1284
1285 // We do this before calling EntryAvailable to force any further calls to 1285 // We do this before calling EntryAvailable to force any further calls to
1286 // AddTransactionToEntry to add their transaction to the pending queue, which 1286 // AddTransactionToEntry to add their transaction to the pending queue, which
1287 // ensures FIFO ordering. 1287 // ensures FIFO ordering.
1288 if (!entry->pending_queue.empty()) 1288 if (!entry->writer && !entry->pending_queue.empty())
1289 ProcessPendingQueue(entry); 1289 ProcessPendingQueue(entry);
1290 1290
1291 return trans->EntryAvailable(entry); 1291 return trans->EntryAvailable(entry);
1292 } 1292 }
1293 1293
1294 void HttpCache::DoneWithEntry(ActiveEntry* entry, Transaction* trans) { 1294 void HttpCache::DoneWithEntry(ActiveEntry* entry, Transaction* trans) {
1295 // If we already posted a task to move on to the next transaction and this was 1295 // If we already posted a task to move on to the next transaction and this was
1296 // the writer, there is nothing to cancel. 1296 // the writer, there is nothing to cancel.
1297 if (entry->will_process_pending_queue && entry->readers.empty()) 1297 if (entry->will_process_pending_queue && entry->readers.empty())
1298 return; 1298 return;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1383 entry->will_process_pending_queue = true; 1383 entry->will_process_pending_queue = true;
1384 1384
1385 MessageLoop::current()->PostTask(FROM_HERE, 1385 MessageLoop::current()->PostTask(FROM_HERE,
1386 task_factory_.NewRunnableMethod(&HttpCache::OnProcessPendingQueue, 1386 task_factory_.NewRunnableMethod(&HttpCache::OnProcessPendingQueue,
1387 entry)); 1387 entry));
1388 } 1388 }
1389 1389
1390 void HttpCache::OnProcessPendingQueue(ActiveEntry* entry) { 1390 void HttpCache::OnProcessPendingQueue(ActiveEntry* entry) {
1391 entry->will_process_pending_queue = false; 1391 entry->will_process_pending_queue = false;
1392 1392
1393 if (entry->writer) 1393 // TODO(rvargas): Convert this to a DCHECK.
1394 return; 1394 CHECK(!entry->writer);
1395 1395
1396 // If no one is interested in this entry, then we can de-activate it. 1396 // If no one is interested in this entry, then we can de-activate it.
1397 if (entry->pending_queue.empty()) { 1397 if (entry->pending_queue.empty()) {
1398 if (entry->readers.empty()) 1398 if (entry->readers.empty())
1399 DestroyEntry(entry); 1399 DestroyEntry(entry);
1400 return; 1400 return;
1401 } 1401 }
1402 1402
1403 // Promote next transaction from the pending queue. 1403 // Promote next transaction from the pending queue.
1404 Transaction* next = entry->pending_queue.front(); 1404 Transaction* next = entry->pending_queue.front();
1405 if ((next->mode() & Transaction::WRITE) && !entry->readers.empty()) 1405 if ((next->mode() & Transaction::WRITE) && !entry->readers.empty())
1406 return; // have to wait 1406 return; // have to wait
1407 1407
1408 entry->pending_queue.erase(entry->pending_queue.begin()); 1408 entry->pending_queue.erase(entry->pending_queue.begin());
1409 1409
1410 AddTransactionToEntry(entry, next); 1410 AddTransactionToEntry(entry, next);
1411 } 1411 }
1412 1412
1413 //----------------------------------------------------------------------------- 1413 //-----------------------------------------------------------------------------
1414 1414
1415 } // namespace net 1415 } // namespace net
1416 1416
OLDNEW
« no previous file with comments | « no previous file | net/http/http_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698