| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "base/file_path.h" | 5 #include "base/file_path.h" |
| 6 #include "base/logging.h" | 6 #include "base/logging.h" |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| 11 #include "net/base/io_buffer.h" | 11 #include "net/base/io_buffer.h" |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 if (input_->msg.result == RESULT_NAME_OVERFLOW) { | 360 if (input_->msg.result == RESULT_NAME_OVERFLOW) { |
| 361 // The key is too long. Just move on. | 361 // The key is too long. Just move on. |
| 362 printf("Skipping entry (name too long)\n"); | 362 printf("Skipping entry (name too long)\n"); |
| 363 return SendGetPrevEntry(); | 363 return SendGetPrevEntry(); |
| 364 } | 364 } |
| 365 | 365 |
| 366 if (input_->msg.result != RESULT_OK) | 366 if (input_->msg.result != RESULT_OK) |
| 367 return Fail(); | 367 return Fail(); |
| 368 | 368 |
| 369 std::string key(input_->buffer); | 369 std::string key(input_->buffer); |
| 370 DCHECK(key.size() == static_cast<size_t>(input_->msg.buffer_bytes - 1)); | 370 DCHECK(key.size() == input_->msg.buffer_bytes - 1); |
| 371 | 371 |
| 372 if (!writer_->CreateEntry(key, | 372 if (!writer_->CreateEntry(key, |
| 373 reinterpret_cast<disk_cache::Entry**>(&entry_))) { | 373 reinterpret_cast<disk_cache::Entry**>(&entry_))) { |
| 374 printf("Skipping entry \"%s\": %d\n", key.c_str(), GetLastError()); | 374 printf("Skipping entry \"%s\" (name conflict!)\n", key.c_str()); |
| 375 return SendGetPrevEntry(); | 375 return SendGetPrevEntry(); |
| 376 } | 376 } |
| 377 | 377 |
| 378 if (key.size() >= 64) { | 378 if (key.size() >= 64) { |
| 379 key[60] = '.'; | 379 key[60] = '.'; |
| 380 key[61] = '.'; | 380 key[61] = '.'; |
| 381 key[62] = '.'; | 381 key[62] = '.'; |
| 382 key[63] = '\0'; | 382 key[63] = '\0'; |
| 383 } | 383 } |
| 384 DEBUGMSG("Entry \"%s\" created\n", key.c_str()); | 384 DEBUGMSG("Entry \"%s\" created\n", key.c_str()); |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 Message msg; | 691 Message msg; |
| 692 msg.command = GET_KEY; | 692 msg.command = GET_KEY; |
| 693 | 693 |
| 694 if (!entry_ || input_->msg.long_arg1 != reinterpret_cast<int64>(entry_)) { | 694 if (!entry_ || input_->msg.long_arg1 != reinterpret_cast<int64>(entry_)) { |
| 695 msg.result = RESULT_INVALID_PARAMETER; | 695 msg.result = RESULT_INVALID_PARAMETER; |
| 696 } else { | 696 } else { |
| 697 std::string key = entry_->GetKey(); | 697 std::string key = entry_->GetKey(); |
| 698 msg.buffer_bytes = std::min(key.size() + 1, | 698 msg.buffer_bytes = std::min(key.size() + 1, |
| 699 static_cast<size_t>(kBufferSize)); | 699 static_cast<size_t>(kBufferSize)); |
| 700 memcpy(output_->buffer, key.c_str(), msg.buffer_bytes); | 700 memcpy(output_->buffer, key.c_str(), msg.buffer_bytes); |
| 701 if (msg.buffer_bytes != static_cast<int32>(key.size() + 1)) { | 701 if (msg.buffer_bytes != key.size() + 1) { |
| 702 // We don't support moving this entry. Just tell the master. | 702 // We don't support moving this entry. Just tell the master. |
| 703 msg.result = RESULT_NAME_OVERFLOW; | 703 msg.result = RESULT_NAME_OVERFLOW; |
| 704 } else { | 704 } else { |
| 705 msg.result = RESULT_OK; | 705 msg.result = RESULT_OK; |
| 706 } | 706 } |
| 707 } | 707 } |
| 708 SendMsg(msg); | 708 SendMsg(msg); |
| 709 } | 709 } |
| 710 | 710 |
| 711 void SlaveSM::DoGetUseTimes() { | 711 void SlaveSM::DoGetUseTimes() { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 | 820 |
| 821 SlaveSM slave(input_path, pipe); | 821 SlaveSM slave(input_path, pipe); |
| 822 if (!slave.DoInit()) { | 822 if (!slave.DoInit()) { |
| 823 printf("Unable to talk with the main process\n"); | 823 printf("Unable to talk with the main process\n"); |
| 824 return -1; | 824 return -1; |
| 825 } | 825 } |
| 826 | 826 |
| 827 loop.Run(); | 827 loop.Run(); |
| 828 return 0; | 828 return 0; |
| 829 } | 829 } |
| OLD | NEW |